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
This commit is contained in:
parent
68e16c26dd
commit
25c3c061b5
2 changed files with 8 additions and 4 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue