jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/374038 )

Change subject: Fix/hack ErrorPageError to work from non-UI contexts
......................................................................


Fix/hack ErrorPageError to work from non-UI contexts

Right now, ErrorPageError *assumes* you're never running on the cli
or the API. It's kinda a crappy superclass to use for errors unless
you're 1000% sure you'll never hit that code path. Yay assumptions!

Ideally, all of this report() crap is cleaned up and unified across
the like 1192902117 places we have it spread out, but for now just
detect the scenario and delegate back to MWException, which does the
right thing

Bug: T168337
Change-Id: Ia2f490528e128527a7a5ef1f4f5eea36ec9ee810
---
M includes/exception/ErrorPageError.php
M tests/phpunit/includes/exception/ErrorPageErrorTest.php
2 files changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified
  Zoranzoki21: Looks good to me, but someone else must approve



diff --git a/includes/exception/ErrorPageError.php 
b/includes/exception/ErrorPageError.php
index 2f502d8..97ba56b 100644
--- a/includes/exception/ErrorPageError.php
+++ b/includes/exception/ErrorPageError.php
@@ -53,9 +53,12 @@
        }
 
        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();
+               }
        }
 }
diff --git a/tests/phpunit/includes/exception/ErrorPageErrorTest.php 
b/tests/phpunit/includes/exception/ErrorPageErrorTest.php
index 71398e3..e72865f 100644
--- a/tests/phpunit/includes/exception/ErrorPageErrorTest.php
+++ b/tests/phpunit/includes/exception/ErrorPageErrorTest.php
@@ -43,6 +43,7 @@
                $mock->expects( $this->once() )
                        ->method( 'output' );
                $this->setMwGlobals( 'wgOut', $mock );
+               $this->setMwGlobals( 'wgCommandLineMode', false );
 
                $e = new ErrorPageError( $title, $mockMessage, $params );
                $e->report();

-- 
To view, visit https://gerrit.wikimedia.org/r/374038
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2f490528e128527a7a5ef1f4f5eea36ec9ee810
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Zoranzoki21 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to