BUG Make process_dirty_indexes act cleanly

process_dirty_indexes wasnt saving variant state or restoring or exit, because
I thought it was only called at the end of a request and so didnt need to

But tests call it regularly throughout a request. So now its clean
and safe to call when-ever
This commit is contained in:
Hamish Friedlander 2012-07-19 17:07:48 +12:00
parent f4fd71665a
commit e5bf1473d6
1 changed files with 4 additions and 2 deletions

View File

@ -232,13 +232,13 @@ class SearchUpdater extends Object {
/**
* Internal function. Process the passed list of dirty ids. Split from flush_dirty_indexes so it can be called both
* directly and via messagequeue message.
*
* WARNING: Changes state (subsite, stage) and doesn't reset it. Should only be called after request has ended
*/
static function process_dirty_indexes($dirty) {
$indexes = FullTextSearch::get_indexes();
$dirtyindexes = array();
$originalState = SearchVariant::current_state();
foreach ($dirty as $base => $statefulids) {
if (!$statefulids) continue;
@ -263,6 +263,8 @@ class SearchUpdater extends Object {
foreach ($dirtyindexes as $index) {
$indexes[$index]->commit();
}
SearchVariant::activate_state($originalState);
}
}