Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/90552


Change subject: Add $wgSemiprotectedRestrictionLevels
......................................................................

Add $wgSemiprotectedRestrictionLevels

It's possible that a wiki could introduce new protection levels that
should be considered "semiprotected". For example, if an
"emailconfirmed" protection level were added and an appropriate entry
were made in $wgAutopromote, that might be considered semi-protection
since anyone can automatically gain the ability to edit those pages
merely by setting and confirming their email address.

The most straightforward way to take care of this is to add a config
variable to specify which protection levels are considered
"semiprotected". So let's do that.

Also, let's take the opportunity to make
$title->isSemiProtected( 'create' ) work correctly.

Bug: 43462
Change-Id: Ic9db6ff6cbd84bd9734be09efbea5a5891197fa0
---
M includes/DefaultSettings.php
M includes/Title.php
2 files changed, 30 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/52/90552/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index a0a1b3e..facb68b 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4366,6 +4366,20 @@
 $wgCascadingRestrictionLevels = array( 'sysop' );
 
 /**
+ * Restriction levels that should be considered "semiprotected"
+ *
+ * Certain places in the interface recognize a dichotomy between "protected"
+ * and "semiprotected", without further distinguishing the specific levels. In
+ * general, if anyone can be eligible to edit a protection level merely by
+ * reaching some condition in $wgAutopromote, it should probably be considered
+ * "semiprotected".
+ *
+ * 'autoconfirmed' is quietly rewritten to 'editsemiprotected' for backwards 
compatibility.
+ * 'sysop' is not changed, since it really shouldn't be here.
+ */
+$wgSemiprotectedRestrictionLevels = array( 'autoconfirmed' );
+
+/**
  * Set the minimum permissions required to edit pages in each
  * namespace.  If you list more than one permission, a user must
  * have all of them to edit pages in that namespace.
diff --git a/includes/Title.php b/includes/Title.php
index 56e9b44..8a2658b 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2464,25 +2464,24 @@
         * @return Bool
         */
        public function isSemiProtected( $action = 'edit' ) {
-               if ( $this->exists() ) {
-                       $restrictions = $this->getRestrictions( $action );
-                       if ( count( $restrictions ) > 0 ) {
-                               foreach ( $restrictions as $restriction ) {
-                                       if ( strtolower( $restriction ) != 
'editsemiprotected' &&
-                                               strtolower( $restriction ) != 
'autoconfirmed' // BC
-                                       ) {
-                                               return false;
-                                       }
-                               }
-                       } else {
-                               # Not protected
-                               return false;
-                       }
-                       return true;
-               } else {
-                       # If it doesn't exist, it can't be protected
+               global $wgSemiprotectedRestrictionLevels;
+
+               $restrictions = $this->getRestrictions( $action );
+               $semi = $wgSemiprotectedRestrictionLevels;
+               if ( !$restrictions || !$semi ) {
+                       // Not protected, or all protection is full protection
                        return false;
                }
+
+               // Remap autoconfirmed to editsemiprotected for BC
+               foreach ( array_keys( $semi, 'autoconfirmed' ) as $key ) {
+                       $semi[$key] = 'editsemiprotected';
+               }
+               foreach ( array_keys( $restrictions, 'autoconfirmed' ) as $key 
) {
+                       $restrictions[$key] = 'editsemiprotected';
+               }
+
+               return !array_diff( $restrictions, $semi );
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9db6ff6cbd84bd9734be09efbea5a5891197fa0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to