Merge "jquery.suggestions: Trigger keypress on initializing"
[lhc/web/wiklou.git] / includes / actions / Action.php
index e5233f0..f892c5e 100644 (file)
@@ -101,8 +101,7 @@ abstract class Action implements MessageLocalizer {
                        if ( !class_exists( $classOrCallable ) ) {
                                return false;
                        }
-                       $obj = new $classOrCallable( $page, $context );
-                       return $obj;
+                       return new $classOrCallable( $page, $context );
                }
 
                if ( is_callable( $classOrCallable ) ) {
@@ -142,7 +141,7 @@ abstract class Action implements MessageLocalizer {
                        } else {
                                $actionName = 'view';
                        }
-               } elseif ( $actionName == 'editredlink' ) {
+               } elseif ( $actionName === 'editredlink' ) {
                        $actionName = 'edit';
                }
 
@@ -314,9 +313,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
@@ -354,7 +358,7 @@ abstract class Action implements MessageLocalizer {
         */
        protected function setHeaders() {
                $out = $this->getOutput();
-               $out->setRobotPolicy( "noindex,nofollow" );
+               $out->setRobotPolicy( 'noindex,nofollow' );
                $out->setPageTitle( $this->getPageTitle() );
                $out->setSubtitle( $this->getDescription() );
                $out->setArticleRelated( true );