Merge "Fix/hack ErrorPageError to work from non-UI contexts"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 6 Jul 2017 20:28:37 +0000 (20:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 6 Jul 2017 20:28:37 +0000 (20:28 +0000)
includes/exception/ErrorPageError.php
tests/phpunit/includes/exception/ErrorPageErrorTest.php

index 2bed87a..4b18126 100644 (file)
@@ -61,9 +61,12 @@ class ErrorPageError extends MWException implements ILocalizedException {
        }
 
        public function report() {
-               global $wgOut;
-
-               $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
-               $wgOut->output();
+               if ( self::isCommandLine() || defined( 'MW_API' ) ) {
+                       parent::report();
+               } else {
+                       global $wgOut;
+                       $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
+                       $wgOut->output();
+               }
        }
 }
index 71398e3..e72865f 100644 (file)
@@ -43,6 +43,7 @@ class ErrorPageErrorTest extends MediaWikiTestCase {
                $mock->expects( $this->once() )
                        ->method( 'output' );
                $this->setMwGlobals( 'wgOut', $mock );
+               $this->setMwGlobals( 'wgCommandLineMode', false );
 
                $e = new ErrorPageError( $title, $mockMessage, $params );
                $e->report();