Don't fall back to global $wgUser when creating ParserOptions

Pass a user when relevant, or use ParserOptions::newFromAnon()

Bug: T246861
Change-Id: I44adb6d5c037de2fb05573cde3c7356cb73e8b42
This commit is contained in:
DannyS712 2020-03-07 02:31:53 +00:00
parent f5c78fba8d
commit fb850e853c
3 changed files with 9 additions and 4 deletions

View file

@ -95,7 +95,7 @@ class ApiScribuntoConsole extends ApiBase {
*/
protected function runConsole( array $params ) {
$parser = MediaWikiServices::getInstance()->getParser();
$options = new ParserOptions;
$options = new ParserOptions( $this->getUser() );
$parser->startExternalParse( $params['title'], $options, Parser::OT_HTML, true );
$engine = Scribunto::getParserEngine( $parser );
try {

View file

@ -45,7 +45,12 @@ trait Scribunto_LuaEngineTestHelper {
try {
$parser = new Parser;
$parser->startExternalParse( Title::newMainPage(), new ParserOptions, Parser::OT_HTML, true );
$parser->startExternalParse(
Title::newMainPage(),
ParserOptions::newFromAnon(),
Parser::OT_HTML,
true
);
$engineClass = "Scribunto_{$engineName}Engine";
$engine = new $engineClass(
self::$engineConfigurations[$engineName] + [ 'parser' => $parser ]
@ -119,7 +124,7 @@ trait Scribunto_LuaEngineTestHelper {
protected function getEngine() {
if ( !$this->engine ) {
$parser = new Parser;
$options = new ParserOptions;
$options = ParserOptions::newFromAnon();
$options->setTemplateCallback( [ $this, 'templateCallback' ] );
$parser->startExternalParse( $this->getTestTitle(), $options, Parser::OT_HTML, true );
$class = "Scribunto_{$this->engineName}Engine";

View file

@ -26,7 +26,7 @@ class Scribunto_LuaEnvironmentComparisonTest extends PHPUnit\Framework\TestCase
private function makeEngine( $class, $opts ) {
$parser = new Parser;
$options = new ParserOptions;
$options = ParserOptions::newFromAnon();
$options->setTemplateCallback( [ $this, 'templateCallback' ] );
$parser->startExternalParse( Title::newMainPage(), $options, Parser::OT_HTML, true );
$engine = new $class ( [ 'parser' => $parser ] + $opts );