Merge "Fix unit tests when $wgEmailAuthentication is set to false"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 12 May 2013 08:13:15 +0000 (08:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 12 May 2013 08:13:15 +0000 (08:13 +0000)
RELEASE-NOTES-1.22
includes/DefaultSettings.php
includes/ProtectionForm.php
includes/WikiPage.php
maintenance/copyFileBackend.php

index 07afffe..ad12bf9 100644 (file)
@@ -15,6 +15,7 @@ production.
   activated; when $wgUseVFormCreateAccount is true, the redesign of
   Special:UserLogin/signup is activated.
 * $wgVectorUseIconWatch is now enabled by default.
+* $wgCascadingRestrictionLevels was added.
 
 === New features in 1.22 ===
 * (bug 44525) mediawiki.jqueryMsg can now parse (whitelisted) HTML elements and attributes.
@@ -67,6 +68,8 @@ production.
 * mediawiki.log: Added log.warn wrapper (uses console.warn and console.trace).
 * mediawiki.log: Implemented log.deprecate. This method defines a property and
   uses ES5 getter/setter to emit a warning when they are used.
+* $wgCascadingRestrictionLevels was added, allowing one to specify restriction levels
+  which can be cascading (previously 'sysop' was hard-coded as the only one).
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail. Previously one could still
index 5330caf..46ca7ed 100644 (file)
@@ -4044,6 +4044,21 @@ $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' );
  */
 $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' );
 
+/**
+ * Restriction levels that can be used with cascading protection
+ *
+ * A page can only be protected with cascading protection if the
+ * requested restriction level is included in this array.
+ *
+ * This is intended to prevent abuse - if any protection could be
+ * cascading, users could who cannot normally protect pages could
+ * "protect" them by transcluding them on protected pages they are
+ * allowed to edit.
+ *
+ * 'sysop' is quietly rewritten to 'protect' for backwards compatibility.
+ */
+$wgCascadingRestrictionLevels = array( 'sysop' );
+
 /**
  * Set the minimum permissions required to edit pages in each
  * namespace.  If you list more than one permission, a user must
index 9439b90..0ac8749 100644 (file)
@@ -614,16 +614,9 @@ class ProtectionForm {
        }
 
        function buildCleanupScript() {
-               global $wgRestrictionLevels, $wgOut;
+               global $wgRestrictionLevels, $wgCascadingRestrictionLevels, $wgOut;
 
-               $cascadeableLevels = array();
-               foreach ( $wgRestrictionLevels as $key ) {
-                       if ( User::groupHasPermission( $key, 'protect' )
-                               || $key == 'protect'
-                       ) {
-                               $cascadeableLevels[] = $key;
-                       }
-               }
+               $cascadeableLevels = $wgCascadingRestrictionLevels;
                $options = array(
                        'tableId' => 'mwProtectSet',
                        'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
index f2c9c29..da6fff3 100644 (file)
@@ -2221,7 +2221,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @return Status
         */
        public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
-               global $wgContLang;
+               global $wgContLang, $wgCascadingRestrictionLevels;
 
                if ( wfReadOnly() ) {
                        return Status::newFatal( 'readonlytext', wfReadOnlyReason() );
@@ -2344,12 +2344,17 @@ class WikiPage implements Page, IDBAccessObject {
                                return Status::newGood();
                        }
 
-                       // Only restrictions with the 'protect' right can cascade...
-                       // Otherwise, people who cannot normally protect can "protect" pages via transclusion
+                       // Only certain restrictions can cascade... Otherwise, users who cannot normally protect pages
+                       // could "protect" them by transcluding them on protected pages they are allowed to edit.
                        $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
 
+                       $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
+                       if ( in_array( 'sysop', $cascadingRestrictionLevels ) ) {
+                               $cascadingRestrictionLevels[] = 'protect'; // backwards compatibility
+                       }
+
                        // The schema allows multiple restrictions
-                       if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) ) {
+                       if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) {
                                $cascade = false;
                        }
 
index 6846edf..736910a 100644 (file)
@@ -192,8 +192,9 @@ class CopyFileBackend extends Maintenance {
                                if ( $src->fileExists( array( 'src' => $srcPath ) ) === false ) {
                                        $this->error( "File '$srcPath' was listed be must have been deleted." );
                                } else {
-                                       $this->error( "Could not get local copy of $srcPath.", 1 ); // die
+                                       $this->error( "Could not get local copy of $srcPath." );
                                }
+                               continue;
                        } elseif ( !$fsFile->exists() ) {
                                // FSFileBackends just return the path for getLocalReference() and paths with
                                // illegal slashes may get normalized to a different path. This can cause the