X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FAction.php;h=f288a5cb1f3fa5176fecf004840d663266211e90;hb=d37ab34a870ec65b5cd678882ffdff4a8795f8dd;hp=e8d9a3e4029a411727fd1b07dc52b8be37996001;hpb=3df3b575c6617df64ec98533cc7141bd2314e274;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/Action.php b/includes/actions/Action.php index e8d9a3e402..f288a5cb1f 100644 --- a/includes/actions/Action.php +++ b/includes/actions/Action.php @@ -19,6 +19,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * @defgroup Actions Action done on pages */ @@ -28,7 +30,7 @@ * are distinct from Special Pages because an action must apply to exactly one page. * * To add an action in an extension, create a subclass of Action, and add the key to - * $wgActions. There is also the deprecated UnknownAction hook + * $wgActions. * * Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input * format (protect, delete, move, etc), and the just-do-something format (watch, rollback, @@ -104,7 +106,7 @@ abstract class Action implements MessageLocalizer { } if ( is_callable( $classOrCallable ) ) { - return call_user_func_array( $classOrCallable, [ $page, $context ] ); + return $classOrCallable( $page, $context ); } return $classOrCallable; @@ -130,7 +132,7 @@ abstract class Action implements MessageLocalizer { $actionName = 'nosuchaction'; } - // Workaround for bug #20966: inability of IE to provide an action dependent + // Workaround for T22966: inability of IE to provide an action dependent // on which submit button is clicked. if ( $actionName === 'historysubmit' ) { if ( $request->getBool( 'revisiondelete' ) ) { @@ -255,7 +257,7 @@ abstract class Action implements MessageLocalizer { */ final public function msg( $key ) { $params = func_get_args(); - return call_user_func_array( [ $this->getContext(), 'msg' ], $params ); + return $this->getContext()->msg( ...$params ); } /** @@ -312,9 +314,14 @@ abstract class Action implements MessageLocalizer { } } - if ( $this->requiresUnblock() && $user->isBlocked() ) { + // If the action requires an unblock, explicitly check the user's block. + if ( $this->requiresUnblock() && $user->isBlockedFrom( $this->getTitle() ) ) { $block = $user->getBlock(); - throw new UserBlockedError( $block ); + if ( $block ) { + throw new UserBlockedError( $block ); + } + + throw new PermissionsError( $this->getName(), [ 'badaccess-group0' ] ); } // This should be checked at the end so that the user won't think the @@ -386,8 +393,7 @@ abstract class Action implements MessageLocalizer { * @since 1.25 */ public function addHelpLink( $to, $overrideBaseUrl = false ) { - global $wgContLang; - $msg = wfMessage( $wgContLang->lc( + $msg = wfMessage( MediaWikiServices::getInstance()->getContentLanguage()->lc( self::getActionName( $this->getContext() ) ) . '-helppage' );