r36478 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36477‎ | r36478 | r36479 >
Date:20:40, 19 June 2008
Author:ialex
Status:old
Tags:
Comment:
Note that restrictions are rights, not groups. So now, cascading protection will be allowed if all groups that have the right being check have the 'protect' right too.
Modified paths:
  • /trunk/phase3/extensions (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Property changes on: trunk/phase3/extensions
___________________________________________________________________
Added: svn:ignore
11 + AbsenteeLandlord
ActiveAbstract
AdvancedRandom
Aggregator
AjaxQueryPages
AjaxShowEditors
AjaxTest
AntiSpoof
APC
Asksql
AssertEdit
auth
AuthorProtect
Autoincrement
AutomaticGroups
Babel
BackAndForth
BadImage
Blahtex
BlockTitles
BoardVote
BookInformation
BotQuery
BreadCrumbs
Cache404
Call
CategoryIntersection
CategoryStepper
CategoryTree
catfeed
CentralAuth
CentralNotice
ChangeAuthor
CharInsert
CheckUser
Chemistry
Citation
Cite
cldr
CleanChanges
Click
Collection
CommentPages
CommentSpammer
Configure
ConfirmAccount
ConfirmEdit
ContactPage
ContributionScores
Contributionseditcount
Contributors
ContributorsAddon
CountEdits
CreateBox
CrossNamespaceLinks
Crosswiki
CrowdAuthentication
Data
DataTransfer
DeletedContributions
Desysop
DidYouMean
DisableSpecialPages
DismissableSiteNotice
DoubleWiki
DPLforum
DumpHTML
Duplicator
DynamicPageList
DynamicPageList2
Editcount
EditMessages
EditOwn
EditSubpages
EditUser
ee
EmailAddressImage
EmailArticle
ErrorHandler
Eval
examples
ExpandTemplates
experimental
ExtensionLoader
Farmer
FastStringSearch
FCKeditor
Filepath
FileSearch
FindSpam
FixedImage
FlaggedRevs
FootNote
ForcePreview
FormatDates
FormatEmail
FormPreloadPostCache
Gadgets
geo
geoserver
gis
GiveRollback
GlobalBlocking
GlobalUsage
Gnuplot
googleAnalytics
GoogleMaps
GoToCategory
GroupPortal
HTMLets
HTTPRedirect
I18nTags
Icon
icpagent
ImageMap
Imagetabs
ImageTagging
ImportFreeImages
ImportUsers
inputbox
InspectCache
InstantCommons
interact
intersection
Interwiki
Invitations
JIRA
LabeledSectionTransclusion
LanguageSelector
LatexDoc
LdapAuthentication
LinkSearch
LiquidThreads
ListChangedArticles
LocalFileLink
Lockdown
Logo
LookupUser
LuceneSearch
MagicNoNumberedHeadings
Maintenance
Makebot
MakeDBError
Makesysop
MathStatFunctions
MediaFunctions
Memorize
MetavidWiki
METIS
Mibbit
MicroID
MiniDonation
MinimumNameLength
MiniPreview
MogileClient
MultiBoilerplate
Multilang
MultiUpload
MWBlocker
MWSearch
NavigationPopups
NetworkAuth
NewestPages
News
Newuserlog
NewUserMessage
NewUserNotif
Nogomatch
NopurgeRC
normal
Nuke
OAI
OggHandler
OnlineStatus
OpenID
Oversight
PageBy
PageCSS
PageNotice
ParserDiffTest
ParserFunctions
PasswordReset
Patroller
PdfHandler
pecl-proctitle
php
phpbbData
Player
PNGHandler
Poem
Polyglot
Postcomment
PovWatch
Preloader
PrivateNamespaces
ProfileMonitor
ProofreadPage
ProtectSection
Purge
PurgeCache
purgetab
Quiz
RandomImage
RandomInCategory
Randomrootpage
RDF
redircite
regexBlock
Renameuser
RenderHash
ReplaceText
Resign
Review
RightFunctions
rss
sampleskin
ScanSet
Seealso
SelectCategory
SemanticCalendar
SemanticDrilldown
SemanticForms
SemanticMediaWiki
ShowProcesslist
SignDocument
SimpleAntiSpam
SimplifiedRegex
SisterSites
SiteMatrix
SkinPerNamespace
SkinPerPage
skins
SmoothGallery
SocialProfile
Sort
SpamBlacklist
SpamDiffTool
SpamRegex
SpecialFileList
SpecialForm
SpecialTalk
StableVersion
StalePages
StaticWiki
StringFunctions
SubpageList
SubPageList3
SyntaxHighlight_GeSHi
SyntaxHighlight_vim
Syslog
TalkHere
Tasks
TemplateLink
Throttle
tidy
TidyTab
timeline
TitleBlacklist
TitleKey
Todo
TodoTasks
Tooltip
Translate
transliterate
TreeAndMenu
UnicodeConverter
UsageStatistics
UserContactLinks
UserImages
Userip
UserMerge
UsernameBlacklist
UserRightsNotif
Vote
Watchers
WatchSubpages
WebStore
WhiteList
WhoIsWatching
WhosOnline
Wikidata
wikidiff
wikidiff2
wikiforum
wikihiero
WikiMiniAtlas
wikiwyg
WiktionaryInflection
Woopra
YouTubeAuthSub
zhdaemon
Index: trunk/phase3/includes/ProtectionForm.php
@@ -91,8 +91,7 @@
9292 global $wgRequest, $wgOut;
9393 if( $wgRequest->wasPosted() ) {
9494 if( $this->save() ) {
95 - $article = new Article( $this->mTitle );
96 - $q = $article->isRedirect() ? 'redirect=no' : '';
 95+ $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
9796 $wgOut->redirect( $this->mTitle->getFullUrl( $q ) );
9897 }
9998 } else {
@@ -190,17 +189,10 @@
191190
192191 }
193192
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;
 193+ # NOTE : verification of cascading protection in semi-protection mode
 194+ # is in Article::updateRestriction()
197195
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()) {
 196+ if( $this->mTitle->exists() ){
205197 $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry );
206198 } else {
207199 $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry );
@@ -379,7 +371,15 @@
380372 $script = 'var wgCascadeableLevels=';
381373 $CascadeableLevels = array();
382374 foreach( $wgRestrictionLevels as $key ) {
383 - if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
 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 ) {
384384 $CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
385385 }
386386 }
Index: trunk/phase3/includes/Article.php
@@ -16,26 +16,26 @@
1717 /**@{{
1818 * @private
1919 */
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; //!<
4040 var $mIsRedirect;
4141 /**@}}*/
4242
@@ -543,9 +543,9 @@
544544 */
545545 function isRedirect( $text = false ) {
546546 if ( $text === false ) {
547 - if ( $this->mDataLoaded )
 547+ if ( $this->mDataLoaded )
548548 return $this->mIsRedirect;
549 -
 549+
550550 // Apparently loadPageData was never called
551551 $this->loadContent();
552552 $titleObj = Title::newFromRedirect( $this->fetchContent() );
@@ -924,14 +924,14 @@
925925 $this->viewUpdates();
926926 wfProfileOut( __METHOD__ );
927927 }
928 -
 928+
929929 protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) {
930930 global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
931 -
 931+
932932 # Display redirect
933933 $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
934934 $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
935 -
 935+
936936 if( $overwriteSubtitle ) {
937937 $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
938938 }
@@ -943,7 +943,7 @@
944944
945945 $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
946946 '<span class="redirectText">'.$link.'</span>' );
947 -
 947+
948948 }
949949
950950 function addTrackbacks() {
@@ -1451,7 +1451,7 @@
14521452
14531453 # Update page
14541454 $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
1455 -
 1455+
14561456 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) );
14571457
14581458 if( !$ok ) {
@@ -1523,7 +1523,7 @@
15241524
15251525 # Update the page record with revision data
15261526 $this->updateRevisionOn( $dbw, $revision, 0 );
1527 -
 1527+
15281528 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
15291529
15301530 if( !( $flags & EDIT_SUPPRESS_RC ) ) {
@@ -1835,11 +1835,18 @@
18361836 }
18371837 $comment = $wgContLang->ucfirst( wfMsgForContent( $comment_type, $this->mTitle->getPrefixedText() ) );
18381838
 1839+ # Check if all groups that have required right to edit also can protect pages
 1840+ # Otherwise, people who cannot normally protect can "protect" pages via transclusion
18391841 foreach( $limit as $action => $restrictions ) {
1840 - # Check if the group level required to edit also can protect pages
1841 - # Otherwise, people who cannot normally protect can "protect" pages via transclusion
1842 - $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) &&
1843 - $wgGroupPermissions[$restrictions]['protect'] );
 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+ }
 1850+ }
18441851 }
18451852
18461853 $cascade_description = '';
@@ -1881,9 +1888,9 @@
18821889 'page_latest' => $nullRevId
18831890 ), array( /* WHERE */
18841891 'page_id' => $id
1885 - ), 'Article::protect'
 1892+ ), __METHOD__
18861893 );
1887 -
 1894+
18881895 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
18891896 wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
18901897
@@ -2244,7 +2251,7 @@
22452252 function doDelete( $reason, $suppress = false ) {
22462253 global $wgOut, $wgUser;
22472254 wfDebug( __METHOD__."\n" );
2248 -
 2255+
22492256 $id = $this->getId();
22502257
22512258 if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
@@ -2516,14 +2523,14 @@
25172524 if( empty( $summary ) ){
25182525 $summary = wfMsgForContent( 'revertpage' );
25192526 }
2520 -
 2527+
25212528 # Allow the custom summary to use the same args as the default message
25222529 $args = array(
25232530 $target->getUserText(), $from, $s->rev_id,
25242531 $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
25252532 $current->getId(), $wgLang->timeanddate($current->getTimestamp())
25262533 );
2527 - $summary = wfMsgReplaceArgs( $summary, $args );
 2534+ $summary = wfMsgReplaceArgs( $summary, $args );
25282535
25292536 # Save
25302537 $flags = EDIT_UPDATE;
@@ -2611,7 +2618,7 @@
26122619 . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
26132620 $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
26142621 $wgOut->returnToMain( false, $this->mTitle );
2615 -
 2622+
26162623 if( !$wgRequest->getBool( 'hidediff', false ) ) {
26172624 $de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
26182625 $de->showDiff( '', '' );
@@ -2983,7 +2990,7 @@
29842991 $revision->insertOn( $dbw );
29852992 $this->updateRevisionOn( $dbw, $revision );
29862993 $dbw->commit();
2987 -
 2994+
29882995 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
29892996
29902997 wfProfileOut( __METHOD__ );
Index: trunk/phase3/includes/Title.php
@@ -1219,15 +1219,10 @@
12201220 $right = 'protect';
12211221 }
12221222 if( '' != $right && !$user->isAllowed( $right ) ) {
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 - }
 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!
12321227 } else {
12331228 $errors[] = array( 'protectedpagetext', $right );
12341229 }
@@ -1626,7 +1621,7 @@
16271622
16281623 wfProfileIn( __METHOD__ );
16291624
1630 - $dbr = wfGetDb( DB_SLAVE );
 1625+ $dbr = wfGetDB( DB_SLAVE );
16311626
16321627 if ( $this->getNamespace() == NS_IMAGE ) {
16331628 $tables = array ('imagelinks', 'page_restrictions');
@@ -1927,7 +1922,7 @@
19281923 if ($this->mLatestID !== false)
19291924 return $this->mLatestID;
19301925
1931 - $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
 1926+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
19321927 return $this->mLatestID = $db->selectField( 'revision',
19331928 "max(rev_id)",
19341929 array('rev_page' => $this->getArticleID($flags)),

Follow-up revisions

RevisionCommit summaryAuthorDate
r36519* Revert r36478; I don't see the point in this cryptic code...aaron03:17, 21 June 2008

Status & tagging log