Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / maintenance / preprocessorFuzzTest.php
index 2503ed2..3a43ae8 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 $optionsWithoutArgs = [ 'verbose' ];
 require_once __DIR__ . '/commandLine.inc';
 
@@ -70,7 +72,7 @@ class PPFuzzTester {
                                $passed = 'passed';
                        } catch ( Exception $e ) {
                                $testReport = self::$currentTest->getReport();
-                               $exceptionReport = $e->getText();
+                               $exceptionReport = $e instanceof MWException ? $e->getText() : (string)$e;
                                $hash = md5( $testReport );
                                file_put_contents( "results/ppft-$hash.in", serialize( self::$currentTest ) );
                                file_put_contents( "results/ppft-$hash.fail",
@@ -123,8 +125,7 @@ class PPFuzzTester {
                // This resolves a few differences between the old preprocessor and the
                // XML-based one, which doesn't like illegals and converts line endings.
                // It's done by the MW UI, so it's a reasonably legitimate thing to do.
-               global $wgContLang;
-               $s = $wgContLang->normalize( $s );
+               $s = MediaWikiServices::getInstance()->getContentLanguage()->normalize( $s );
 
                return $s;
        }
@@ -149,6 +150,16 @@ class PPFuzzTester {
 class PPFuzzTest {
        public $templates, $mainText, $title, $entryPoint, $output;
 
+       /** @var PPFuzzTester */
+       private $parent;
+       /** @var string */
+       public $nickname;
+       /** @var bool */
+       public $fancySig;
+
+       /**
+        * @param PPFuzzTester $tester
+        */
        function __construct( $tester ) {
                global $wgMaxSigChars;
                $this->parent = $tester;
@@ -194,7 +205,7 @@ class PPFuzzTest {
        }
 
        function execute() {
-               global $wgParser, $wgUser;
+               global $wgUser;
 
                $wgUser = new PPFuzzUser;
                $wgUser->mName = 'Fuzz';
@@ -205,7 +216,7 @@ class PPFuzzTest {
                $options->setTemplateCallback( [ $this, 'templateHook' ] );
                $options->setTimestamp( wfTimestampNow() );
                $this->output = call_user_func(
-                       [ $wgParser, $this->entryPoint ],
+                       [ MediaWikiServices::getInstance()->getParser(), $this->entryPoint ],
                        $this->mainText,
                        $this->title,
                        $options
@@ -238,7 +249,7 @@ class PPFuzzTest {
 class PPFuzzUser extends User {
        public $ppfz_test, $mDataLoaded;
 
-       function load() {
+       function load( $flags = null ) {
                if ( $this->mDataLoaded ) {
                        return;
                }