mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Ensure that Scribunto exceptions have a page context set
Some exception messages add tracking categories, which fail when there is no title context. Bug: T351045 Change-Id: I47d0160010c9da5a9a9974718a432fd5e79f8286
This commit is contained in:
parent
42212c1172
commit
d97ce9851c
|
@ -155,6 +155,8 @@ abstract class ScribuntoEngineBase {
|
|||
$params = [];
|
||||
if ( $this->title ) {
|
||||
$params['title'] = $this->title;
|
||||
} else {
|
||||
wfDeprecated( __METHOD__ . ' without valid title for engine', '1.42' );
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,13 @@ class ScribuntoException extends Exception {
|
|||
$codeLocation = '[UNKNOWN]';
|
||||
}
|
||||
array_unshift( $this->messageArgs, $codeLocation );
|
||||
$msg = wfMessage( $messageName )->params( $this->messageArgs )->inContentLanguage()->text();
|
||||
parent::__construct( $msg );
|
||||
$msg = wfMessage( $messageName )
|
||||
->params( $this->messageArgs )
|
||||
->inContentLanguage();
|
||||
if ( isset( $params['title'] ) ) {
|
||||
$msg = $msg->page( $params['title'] );
|
||||
}
|
||||
parent::__construct( $msg->text() );
|
||||
|
||||
$this->messageName = $messageName;
|
||||
$this->params = $params;
|
||||
|
|
|
@ -13,6 +13,7 @@ use MediaWiki\Extension\Scribunto\Engines\LuaStandalone\LuaStandaloneInterpreter
|
|||
use MediaWiki\Extension\Scribunto\Engines\LuaStandalone\LuaStandaloneInterpreterFunction;
|
||||
use MediaWiki\Extension\Scribunto\ScribuntoException;
|
||||
use MediaWiki\Extension\Scribunto\Tests\Engines\LuaCommon\LuaInterpreterTestBase;
|
||||
use MediaWiki\Title\Title;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,9 @@ class StandaloneInterpreterTest extends LuaInterpreterTestBase {
|
|||
|
||||
protected function newInterpreter( $opts = [] ) {
|
||||
$opts += $this->stdOpts;
|
||||
$engine = new LuaStandaloneEngine( $this->stdOpts );
|
||||
$engine = new LuaStandaloneEngine( $this->stdOpts + [
|
||||
'title' => Title::makeTitle( NS_MODULE, 'StandaloneInterpreterTest' ),
|
||||
] );
|
||||
return new LuaStandaloneInterpreter( $engine, $opts );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue