public static function validateSearch()
{
// we'll iterate through the inactive search indices in little batches
$offset = 0;
$limit = 50;
while (1) {
// get the inactive indices
$searchResults = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT module, other_id
FROM search_index
WHERE language = ? AND active = ?
GROUP BY module, other_id
LIMIT ?, ?', array(LANGUAGE, 'N', $offset, $limit));
// none found? good news!
if (!$searchResults) {
return;
}
// prepare to send to modules
$moduleResults = array();
// loop the result set
foreach ($searchResults as $searchResult) {
$moduleResults[$searchResult['module']][] = $searchResult['other_id'];
}
// pass the results to the modules
foreach ($moduleResults as $module => $otherIds) {
// check if this module actually is prepared to handle searches
$class = 'Frontend\\Modules\\' . $module . '\\Engine\\Model';
if (is_callable(array($class, 'search'))) {
$moduleResults[$module] = call_user_func(array($class, 'search'), $otherIds);
// update the ones that are allowed to be searched through
self::statusIndex($module, array_keys($moduleResults[$module]), true);
}
}
// didn't even get the amount of result we asked for? no need to ask again!
if (count($searchResults) < $offset) {
return;
}
$offset += $limit;
}
}