Unbreak cascading protection
authorKevin Israel <pleasestand@live.com>
Fri, 5 Jul 2013 21:28:37 +0000 (17:28 -0400)
committerPleaseStand <pleasestand@live.com>
Tue, 9 Jul 2013 18:28:37 +0000 (18:28 +0000)
Title::getRestrictions can return "sysop", which will not match if
replaced out of $cascadingRestrictionLevels but not $editrestriction,
making it impossible to cascade protect a page with the default value
of $wgCascadingRestrictionLevels.

Follows-up I6bf650a3fbdab8589ae6945c8c916eafd949e41c.

Change-Id: Ie7183ed9509ea9c65a7197fc9cead6c8423b852e

includes/WikiPage.php

index 4aab674..910aeae 100644 (file)
@@ -2346,6 +2346,12 @@ class WikiPage implements Page, IDBAccessObject {
                        // 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' );
+                       foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
+                               $editrestriction[$key] = 'editprotected'; // backwards compatibility
+                       }
+                       foreach ( array_keys( $editrestriction, 'autoconfirmed' ) as $key ) {
+                               $editrestriction[$key] = 'editsemiprotected'; // backwards compatibility
+                       }
 
                        $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
                        foreach ( array_keys( $cascadingRestrictionLevels, 'sysop' ) as $key ) {