X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FSpecialPageAction.php;h=8a231cbe5ff53b4380893bc58f3376d786d75bd3;hb=106d0ed034484f96d7f1247932e2754e47848fdf;hp=9b721634d4619bec1a3f7204a386a6705f154bb5;hpb=6b1a173f07f1a04188735f4688ce6335da14c3b7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/SpecialPageAction.php b/includes/actions/SpecialPageAction.php index 9b721634d4..8a231cbe5f 100644 --- a/includes/actions/SpecialPageAction.php +++ b/includes/actions/SpecialPageAction.php @@ -18,6 +18,8 @@ * @ingroup Actions */ +use MediaWiki\MediaWikiServices; + /** * An action that just passes the request to the relevant special page * @@ -25,14 +27,13 @@ * @since 1.25 */ class SpecialPageAction extends FormlessAction { - /** * @var array A mapping of action names to special page names. */ - public static $actionToSpecialPageMapping = array( + public static $actionToSpecialPageMapping = [ 'revisiondelete' => 'Revisiondelete', 'editchangetags' => 'EditTags', - ); + ]; public function getName() { $request = $this->getRequest(); @@ -49,6 +50,7 @@ class SpecialPageAction extends FormlessAction { if ( isset( self::$actionToSpecialPageMapping[$actionName] ) ) { return $actionName; } + return 'nosuchaction'; } @@ -65,15 +67,34 @@ 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 MediaWikiServices::getInstance()->getSpecialPageFactory()-> + getPage( self::$actionToSpecialPageMapping[$action] ); + } }