From 70f6c094e82395fc74540000874ad8e92a24aa89 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 15 Jan 2016 12:34:56 -0800 Subject: [PATCH] Define doesWrites() for SpecialPageAction Bug: T123589 Change-Id: Iede48dea7e3f83f0eb6f21f5cc20b92ff54972a9 --- includes/actions/SpecialPageAction.php | 30 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) 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] ); + } } -- 2.20.1