Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions ting.client.inc
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,27 @@ function ting_get_objects($ids) {
$query[] = 'rec.id=' . $id;
}
}
if (sizeof($query)) {
$request = ting_get_request_factory()->getSearchRequest();
// opensearch is limited to 50 results per call, so iterate until all have been fetched.
$i = 0;
do {
// I query is empty, then don't do it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little typo I => If

// Not necessary to do in each iteration, but it doesn't hurt much.
if (sizeof($query) == 0) {
break;
}

$request = ting_get_request_factory()->getSearchRequest();
if ($agency = variable_get('ting_agency', FALSE)) {
$request->setAgency($agency);
}

$profile = variable_get('ting_search_profile', '');
if (!empty($profile) && method_exists($request, 'setProfile')) {
$request->setProfile($profile);
}

$request->setQuery(join(' OR ', $query));
$request->setStart(1);
$request->setNumResults(1000);
// Do it in steps of 50.
$request->setStart($i * 50 + 1);
$request->setNumResults(50);
$request->setAllObjects(TRUE);

$result = ting_execute_cache($request);
Expand All @@ -137,7 +143,8 @@ function ting_get_objects($ids) {
}
}
}
}
$i++;
} while ($result->more);
return $objects;
}

Expand Down