Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -91,7 +91,8 @@ |
92 | 92 | global $wgRequest, $wgOut; |
93 | 93 | if( $wgRequest->wasPosted() ) { |
94 | 94 | if( $this->save() ) { |
95 | | - $q = $this->mArticle->isRedirect() ? 'redirect=no' : ''; |
| 95 | + $article = new Article( $this->mTitle ); |
| 96 | + $q = $article->isRedirect() ? 'redirect=no' : ''; |
96 | 97 | $wgOut->redirect( $this->mTitle->getFullUrl( $q ) ); |
97 | 98 | } |
98 | 99 | } else { |
— | — | @@ -189,10 +190,17 @@ |
190 | 191 | |
191 | 192 | } |
192 | 193 | |
193 | | - # NOTE : verification of cascading protection in semi-protection mode |
194 | | - # is in Article::updateRestriction() |
| 194 | + # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied |
| 195 | + # to a semi-protected page. |
| 196 | + global $wgGroupPermissions; |
195 | 197 | |
196 | | - if( $this->mTitle->exists() ){ |
| 198 | + $edit_restriction = $this->mRestrictions['edit']; |
| 199 | + |
| 200 | + if ($this->mCascade && ($edit_restriction != 'protect') && |
| 201 | + !(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) ) |
| 202 | + $this->mCascade = false; |
| 203 | + |
| 204 | + if ($this->mTitle->exists()) { |
197 | 205 | $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry ); |
198 | 206 | } else { |
199 | 207 | $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry ); |
— | — | @@ -371,15 +379,7 @@ |
372 | 380 | $script = 'var wgCascadeableLevels='; |
373 | 381 | $CascadeableLevels = array(); |
374 | 382 | foreach( $wgRestrictionLevels as $key ) { |
375 | | - $canCascade = true; |
376 | | - $check = $key == 'sysop' ? 'protect' : $key; |
377 | | - foreach( $wgGroupPermissions as $group => $rights ){ |
378 | | - if( isset( $rights[$check] ) && $rights[$check] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){ |
379 | | - $canCascade = false; |
380 | | - break; |
381 | | - } |
382 | | - } |
383 | | - if( $key != '' && $canCascade ) { |
| 383 | + if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) { |
384 | 384 | $CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'"; |
385 | 385 | } |
386 | 386 | } |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -16,26 +16,26 @@ |
17 | 17 | /**@{{ |
18 | 18 | * @private |
19 | 19 | */ |
20 | | - var $mComment; //!< |
21 | | - var $mContent; //!< |
22 | | - var $mContentLoaded; //!< |
23 | | - var $mCounter; //!< |
24 | | - var $mForUpdate; //!< |
25 | | - var $mGoodAdjustment; //!< |
26 | | - var $mLatest; //!< |
27 | | - var $mMinorEdit; //!< |
28 | | - var $mOldId; //!< |
29 | | - var $mRedirectedFrom; //!< |
30 | | - var $mRedirectUrl; //!< |
31 | | - var $mRevIdFetched; //!< |
32 | | - var $mRevision; //!< |
33 | | - var $mTimestamp; //!< |
34 | | - var $mTitle; //!< |
35 | | - var $mTotalAdjustment; //!< |
36 | | - var $mTouched; //!< |
37 | | - var $mUser; //!< |
38 | | - var $mUserText; //!< |
39 | | - var $mRedirectTarget; //!< |
| 20 | + var $mComment; //!< |
| 21 | + var $mContent; //!< |
| 22 | + var $mContentLoaded; //!< |
| 23 | + var $mCounter; //!< |
| 24 | + var $mForUpdate; //!< |
| 25 | + var $mGoodAdjustment; //!< |
| 26 | + var $mLatest; //!< |
| 27 | + var $mMinorEdit; //!< |
| 28 | + var $mOldId; //!< |
| 29 | + var $mRedirectedFrom; //!< |
| 30 | + var $mRedirectUrl; //!< |
| 31 | + var $mRevIdFetched; //!< |
| 32 | + var $mRevision; //!< |
| 33 | + var $mTimestamp; //!< |
| 34 | + var $mTitle; //!< |
| 35 | + var $mTotalAdjustment; //!< |
| 36 | + var $mTouched; //!< |
| 37 | + var $mUser; //!< |
| 38 | + var $mUserText; //!< |
| 39 | + var $mRedirectTarget; //!< |
40 | 40 | var $mIsRedirect; |
41 | 41 | /**@}}*/ |
42 | 42 | |
— | — | @@ -543,9 +543,9 @@ |
544 | 544 | */ |
545 | 545 | function isRedirect( $text = false ) { |
546 | 546 | if ( $text === false ) { |
547 | | - if ( $this->mDataLoaded ) |
| 547 | + if ( $this->mDataLoaded ) |
548 | 548 | return $this->mIsRedirect; |
549 | | - |
| 549 | + |
550 | 550 | // Apparently loadPageData was never called |
551 | 551 | $this->loadContent(); |
552 | 552 | $titleObj = Title::newFromRedirect( $this->fetchContent() ); |
— | — | @@ -924,14 +924,14 @@ |
925 | 925 | $this->viewUpdates(); |
926 | 926 | wfProfileOut( __METHOD__ ); |
927 | 927 | } |
928 | | - |
| 928 | + |
929 | 929 | protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) { |
930 | 930 | global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser; |
931 | | - |
| 931 | + |
932 | 932 | # Display redirect |
933 | 933 | $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; |
934 | 934 | $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png'; |
935 | | - |
| 935 | + |
936 | 936 | if( $overwriteSubtitle ) { |
937 | 937 | $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
938 | 938 | } |
— | — | @@ -943,7 +943,7 @@ |
944 | 944 | |
945 | 945 | $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . |
946 | 946 | '<span class="redirectText">'.$link.'</span>' ); |
947 | | - |
| 947 | + |
948 | 948 | } |
949 | 949 | |
950 | 950 | function addTrackbacks() { |
— | — | @@ -1451,7 +1451,7 @@ |
1452 | 1452 | |
1453 | 1453 | # Update page |
1454 | 1454 | $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
1455 | | - |
| 1455 | + |
1456 | 1456 | wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) ); |
1457 | 1457 | |
1458 | 1458 | if( !$ok ) { |
— | — | @@ -1523,7 +1523,7 @@ |
1524 | 1524 | |
1525 | 1525 | # Update the page record with revision data |
1526 | 1526 | $this->updateRevisionOn( $dbw, $revision, 0 ); |
1527 | | - |
| 1527 | + |
1528 | 1528 | wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) ); |
1529 | 1529 | |
1530 | 1530 | if( !( $flags & EDIT_SUPPRESS_RC ) ) { |
— | — | @@ -1835,17 +1835,13 @@ |
1836 | 1836 | } |
1837 | 1837 | $comment = $wgContLang->ucfirst( wfMsgForContent( $comment_type, $this->mTitle->getPrefixedText() ) ); |
1838 | 1838 | |
1839 | | - # Check if all groups that have required right to edit also can protect pages |
| 1839 | + # Only restrictions with the 'protect' right can cascade... |
1840 | 1840 | # Otherwise, people who cannot normally protect can "protect" pages via transclusion |
1841 | | - foreach( $limit as $action => $restrictions ) { |
1842 | | - # 'sysop' is checked as 'protect', so it is always allowed |
1843 | | - if ($cascade && ( $restrictions != 'sysop' ) ){ |
1844 | | - foreach( $wgGroupPermissions as $group => $rights ){ |
1845 | | - if( isset( $rights[$restrictions] ) && $rights[$restrictions] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){ |
1846 | | - $cascade = false; |
1847 | | - break( 2 ); |
1848 | | - } |
1849 | | - } |
| 1841 | + foreach( $limit as $action => $restriction ) { |
| 1842 | + # FIXME: can $restriction be an array or what? (same as fixme above) |
| 1843 | + if( $restriction != 'protect' && $restriction != 'sysop' ) { |
| 1844 | + $cascade = false; |
| 1845 | + break; |
1850 | 1846 | } |
1851 | 1847 | } |
1852 | 1848 | |
— | — | @@ -1888,16 +1884,17 @@ |
1889 | 1885 | 'page_latest' => $nullRevId |
1890 | 1886 | ), array( /* WHERE */ |
1891 | 1887 | 'page_id' => $id |
1892 | | - ), __METHOD__ |
| 1888 | + ), 'Article::protect' |
1893 | 1889 | ); |
1894 | | - |
| 1890 | + |
1895 | 1891 | wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) ); |
1896 | 1892 | wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) ); |
1897 | 1893 | |
1898 | 1894 | # Update the protection log |
1899 | 1895 | $log = new LogPage( 'protect' ); |
1900 | 1896 | if( $protect ) { |
1901 | | - $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason . " [$updated]$cascade_description$expiry_description" ) ); |
| 1897 | + $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, |
| 1898 | + trim( $reason . " [$updated]$cascade_description$expiry_description" ) ); |
1902 | 1899 | } else { |
1903 | 1900 | $log->addEntry( 'unprotect', $this->mTitle, $reason ); |
1904 | 1901 | } |
— | — | @@ -2251,7 +2248,7 @@ |
2252 | 2249 | function doDelete( $reason, $suppress = false ) { |
2253 | 2250 | global $wgOut, $wgUser; |
2254 | 2251 | wfDebug( __METHOD__."\n" ); |
2255 | | - |
| 2252 | + |
2256 | 2253 | $id = $this->getId(); |
2257 | 2254 | |
2258 | 2255 | if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) { |
— | — | @@ -2523,14 +2520,14 @@ |
2524 | 2521 | if( empty( $summary ) ){ |
2525 | 2522 | $summary = wfMsgForContent( 'revertpage' ); |
2526 | 2523 | } |
2527 | | - |
| 2524 | + |
2528 | 2525 | # Allow the custom summary to use the same args as the default message |
2529 | 2526 | $args = array( |
2530 | 2527 | $target->getUserText(), $from, $s->rev_id, |
2531 | 2528 | $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true), |
2532 | 2529 | $current->getId(), $wgLang->timeanddate($current->getTimestamp()) |
2533 | 2530 | ); |
2534 | | - $summary = wfMsgReplaceArgs( $summary, $args ); |
| 2531 | + $summary = wfMsgReplaceArgs( $summary, $args ); |
2535 | 2532 | |
2536 | 2533 | # Save |
2537 | 2534 | $flags = EDIT_UPDATE; |
— | — | @@ -2618,7 +2615,7 @@ |
2619 | 2616 | . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() ); |
2620 | 2617 | $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); |
2621 | 2618 | $wgOut->returnToMain( false, $this->mTitle ); |
2622 | | - |
| 2619 | + |
2623 | 2620 | if( !$wgRequest->getBool( 'hidediff', false ) ) { |
2624 | 2621 | $de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true ); |
2625 | 2622 | $de->showDiff( '', '' ); |
— | — | @@ -2990,7 +2987,7 @@ |
2991 | 2988 | $revision->insertOn( $dbw ); |
2992 | 2989 | $this->updateRevisionOn( $dbw, $revision ); |
2993 | 2990 | $dbw->commit(); |
2994 | | - |
| 2991 | + |
2995 | 2992 | wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) ); |
2996 | 2993 | |
2997 | 2994 | wfProfileOut( __METHOD__ ); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1219,10 +1219,15 @@ |
1220 | 1220 | $right = 'protect'; |
1221 | 1221 | } |
1222 | 1222 | if( '' != $right && !$user->isAllowed( $right ) ) { |
1223 | | - // Users with 'editprotected' permission can edit protected |
1224 | | - // pages if protection is not with cascading option turned on. |
1225 | | - if( $action=='edit' && $user->isAllowed( 'editprotected' ) && !$this->areRestrictionsCascading() ) { |
1226 | | - // Nothing, user can edit! |
| 1223 | + //Users with 'editprotected' permission can edit protected pages |
| 1224 | + if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { |
| 1225 | + //Users with 'editprotected' permission cannot edit protected pages |
| 1226 | + //with cascading option turned on. |
| 1227 | + if($this->mCascadeRestriction) { |
| 1228 | + $errors[] = array( 'protectedpagetext', $right ); |
| 1229 | + } else { |
| 1230 | + //Nothing, user can edit! |
| 1231 | + } |
1227 | 1232 | } else { |
1228 | 1233 | $errors[] = array( 'protectedpagetext', $right ); |
1229 | 1234 | } |
— | — | @@ -1621,7 +1626,7 @@ |
1622 | 1627 | |
1623 | 1628 | wfProfileIn( __METHOD__ ); |
1624 | 1629 | |
1625 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 1630 | + $dbr = wfGetDb( DB_SLAVE ); |
1626 | 1631 | |
1627 | 1632 | if ( $this->getNamespace() == NS_IMAGE ) { |
1628 | 1633 | $tables = array ('imagelinks', 'page_restrictions'); |
— | — | @@ -1922,7 +1927,7 @@ |
1923 | 1928 | if ($this->mLatestID !== false) |
1924 | 1929 | return $this->mLatestID; |
1925 | 1930 | |
1926 | | - $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
| 1931 | + $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE); |
1927 | 1932 | return $this->mLatestID = $db->selectField( 'revision', |
1928 | 1933 | "max(rev_id)", |
1929 | 1934 | array('rev_page' => $this->getArticleID($flags)), |