From: jenkins-bot Date: Wed, 20 Jan 2016 00:49:38 +0000 (+0000) Subject: Merge "Define doesWrites() for SpecialPageAction" X-Git-Tag: 1.31.0-rc.0~8279 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=dfd80b414fbc1ebcbf4e0a662aca3706e3ed51c3;hp=fa7279c78d5b8460668d293e5fac226689bccdb5;p=lhc%2Fweb%2Fwiklou.git Merge "Define doesWrites() for SpecialPageAction" --- diff --git a/includes/actions/SpecialPageAction.php b/includes/actions/SpecialPageAction.php index 9b721634d4..29a494bfeb 100644 --- a/includes/actions/SpecialPageAction.php +++ b/includes/actions/SpecialPageAction.php @@ -25,7 +25,6 @@ * @since 1.25 */ class SpecialPageAction extends FormlessAction { - /** * @var array A mapping of action names to special page names. */ @@ -49,6 +48,7 @@ class SpecialPageAction extends FormlessAction { if ( isset( self::$actionToSpecialPageMapping[$actionName] ) ) { return $actionName; } + return 'nosuchaction'; } @@ -65,15 +65,33 @@ class SpecialPageAction extends FormlessAction { } public function show() { - $action = self::getName(); - if ( $action === 'nosuchaction' ) { - throw new ErrorPageError( $this->msg( 'nosuchaction' ), $this->msg( 'nosuchactiontext' ) ); + $special = $this->getSpecialPage(); + if ( !$special ) { + throw new ErrorPageError( + $this->msg( 'nosuchaction' ), $this->msg( 'nosuchactiontext' ) ); } - // map actions to (whitelisted) special pages - $special = SpecialPageFactory::getPage( self::$actionToSpecialPageMapping[$action] ); $special->setContext( $this->getContext() ); $special->getContext()->setTitle( $special->getPageTitle() ); $special->run( '' ); } + + public function doesWrites() { + $special = $this->getSpecialPage(); + + return $special ? $special->doesWrites() : false; + } + + /** + * @return SpecialPage|null + */ + protected function getSpecialPage() { + $action = $this->getName(); + if ( $action === 'nosuchaction' ) { + return null; + } + + // map actions to (whitelisted) special pages + return SpecialPageFactory::getPage( self::$actionToSpecialPageMapping[$action] ); + } }