mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
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:
parent
f4fd71665a
commit
e5bf1473d6
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user