Dbarratt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357016 )

Change subject: Show protection notice a single time when page title is 
protected
......................................................................

Show protection notice a single time when page title is protected

Reorders the access checks when performing the edit action to ensure that the 
errors display in the right order. If a title is protected then the text error 
check is skipped.

Bug: T14458
Change-Id: Ife978a91eec7e788b33e6ea9db9c0d7e2a603399
---
M includes/Title.php
1 file changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/357016/1

diff --git a/includes/Title.php b/includes/Title.php
index a8cfad8..ca94aa9 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2197,10 +2197,17 @@
                        if ( $right == '' ) {
                                continue;
                        }
-                       if ( !$user->isAllowed( $right ) ) {
-                               $errors[] = [ 'protectedpagetext', $right, 
$action ];
-                       } elseif ( $this->mCascadeRestriction && 
!$user->isAllowed( 'protect' ) ) {
-                               $errors[] = [ 'protectedpagetext', 'protect', 
$action ];
+
+                       // Only add the protected page error if the action is 
permitted. If the
+                       // error array is empty, then either 
checkActionPermissions() has not been
+                       // run, or it did not throw an error.
+                       $tempErrors = $this->checkActionPermissions( $action, 
$user, [], $rigor, true );
+                       if ( !$tempErrors || !$errors ) {
+                               if ( !$user->isAllowed( $right ) ) {
+                                       $errors[] = [ 'protectedpagetext', 
$right, $action ];
+                               } elseif ( $this->mCascadeRestriction && 
!$user->isAllowed( 'protect' ) ) {
+                                       $errors[] = [ 'protectedpagetext', 
'protect', $action ];
+                               }
                        }
                }
 
@@ -2328,6 +2335,7 @@
                                $errors[] = [ 'undelete-cantcreate' ];
                        }
                }
+
                return $errors;
        }
 
@@ -2508,9 +2516,9 @@
                        $checks = [
                                'checkQuickPermissions',
                                'checkPermissionHooks',
-                               'checkPageRestrictions',
                                'checkCascadingSourcesRestrictions',
                                'checkActionPermissions',
+                               'checkPageRestrictions',
                                'checkUserBlock'
                        ];
                } else {

-- 
To view, visit https://gerrit.wikimedia.org/r/357016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife978a91eec7e788b33e6ea9db9c0d7e2a603399
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Dbarratt <dbarr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to