$newInstance->redefineService( $name, $callback );
}
+ self::resetGlobalParser();
+
return $newInstance;
}
);
MediaWikiServices::forceGlobalInstance( $newServices );
+
+ self::resetGlobalParser();
+
return $newServices;
}
MediaWikiServices::forceGlobalInstance( self::$originalServices );
$currentServices->destroy();
+ self::resetGlobalParser();
+
return true;
}
+ /**
+ * If $wgParser has been unstubbed, replace it with a fresh one so it picks up any config
+ * changes. $wgParser is deprecated, but we still support it for now.
+ */
+ private static function resetGlobalParser() {
+ // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgParser
+ global $wgParser;
+ if ( $wgParser instanceof StubObject ) {
+ return;
+ }
+ $wgParser = new StubObject( 'wgParser', function () {
+ return MediaWikiServices::getInstance()->getParser();
+ } );
+ }
+
/**
* @since 1.27
* @param string|Language $lang
* Stub. If a test suite needs to test against a specific database schema, it should
* override this method and return the appropriate information from it.
*
+ * 'create', 'drop' and 'alter' in the returned array should list all the tables affected
+ * by the 'scripts', even if the test is only interested in a subset of them, otherwise
+ * the overrides may not be fully cleaned up, leading to errors later.
+ *
* @param IMaintainableDatabase $db The DB connection to use for the mock schema.
* May be used to check the current state of the schema, to determine what
* overrides are needed.