diff --git a/includes/ScribuntoEngineBase.php b/includes/ScribuntoEngineBase.php index 5cc2e351..ac21ca79 100644 --- a/includes/ScribuntoEngineBase.php +++ b/includes/ScribuntoEngineBase.php @@ -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; } diff --git a/includes/ScribuntoException.php b/includes/ScribuntoException.php index 56a8bdca..2015ff0b 100644 --- a/includes/ScribuntoException.php +++ b/includes/ScribuntoException.php @@ -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; diff --git a/tests/phpunit/Engines/LuaStandalone/StandaloneInterpreterTest.php b/tests/phpunit/Engines/LuaStandalone/StandaloneInterpreterTest.php index 755d0263..67e49a5c 100644 --- a/tests/phpunit/Engines/LuaStandalone/StandaloneInterpreterTest.php +++ b/tests/phpunit/Engines/LuaStandalone/StandaloneInterpreterTest.php @@ -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 ); }