FIX: #270 - Reset variant state back to original state after processing

This commit is contained in:
Brett Tasker 2020-01-08 12:46:13 +13:00
parent df8cf3d4cb
commit 72bc71a6a1
1 changed files with 12 additions and 0 deletions

View File

@ -99,6 +99,8 @@ abstract class SolrReindexBase implements SolrReindexHandler
$batchSize,
$taskName
) {
// Get current state
$originalState = SearchVariant::current_state();
// Set state
SearchVariant::activate_state($state);
@ -122,6 +124,9 @@ abstract class SolrReindexBase implements SolrReindexHandler
for ($group = 0; $group < $groups; $group++) {
$this->processGroup($logger, $indexInstance, $state, $class, $groups, $group, $taskName);
}
// Reset state to originalState
SearchVariant::activate_state($originalState);
}
/**
@ -168,7 +173,11 @@ abstract class SolrReindexBase implements SolrReindexHandler
) {
// Set time limit and state
Environment::increaseTimeLimitTo();
// Get current state
$originalState = SearchVariant::current_state();
// Set state
SearchVariant::activate_state($state);
$logger->info("Adding $class");
// Prior to adding these records to solr, delete existing solr records
@ -187,6 +196,9 @@ abstract class SolrReindexBase implements SolrReindexHandler
}
$logger->info("Updated " . implode(',', $processed));
// Reset state to originalState
SearchVariant::activate_state($originalState);
// This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
DB::query('SELECT 1');