diff --git a/code/search/SearchUpdater.php b/code/search/SearchUpdater.php
index <HASH>..<HASH> 100644
--- a/code/search/SearchUpdater.php
+++ b/code/search/SearchUpdater.php
@@ -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);
 	}
 }
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