* Revert r36478; I don't see the point in this cryptic code

* Restore r36273 as explain on mailing list
This commit is contained in:
Aaron Schulz 2008-06-21 03:17:35 +00:00
parent de69d62c0b
commit 7887c332de
3 changed files with 67 additions and 65 deletions

View file

@ -16,26 +16,26 @@ class Article {
/**@{{
* @private
*/
var $mComment; //!<
var $mContent; //!<
var $mContentLoaded; //!<
var $mCounter; //!<
var $mForUpdate; //!<
var $mGoodAdjustment; //!<
var $mLatest; //!<
var $mMinorEdit; //!<
var $mOldId; //!<
var $mRedirectedFrom; //!<
var $mRedirectUrl; //!<
var $mRevIdFetched; //!<
var $mRevision; //!<
var $mTimestamp; //!<
var $mTitle; //!<
var $mTotalAdjustment; //!<
var $mTouched; //!<
var $mUser; //!<
var $mUserText; //!<
var $mRedirectTarget; //!<
var $mComment; //!<
var $mContent; //!<
var $mContentLoaded; //!<
var $mCounter; //!<
var $mForUpdate; //!<
var $mGoodAdjustment; //!<
var $mLatest; //!<
var $mMinorEdit; //!<
var $mOldId; //!<
var $mRedirectedFrom; //!<
var $mRedirectUrl; //!<
var $mRevIdFetched; //!<
var $mRevision; //!<
var $mTimestamp; //!<
var $mTitle; //!<
var $mTotalAdjustment; //!<
var $mTouched; //!<
var $mUser; //!<
var $mUserText; //!<
var $mRedirectTarget; //!<
var $mIsRedirect;
/**@}}*/
@ -543,9 +543,9 @@ class Article {
*/
function isRedirect( $text = false ) {
if ( $text === false ) {
if ( $this->mDataLoaded )
if ( $this->mDataLoaded )
return $this->mIsRedirect;
// Apparently loadPageData was never called
$this->loadContent();
$titleObj = Title::newFromRedirect( $this->fetchContent() );
@ -924,14 +924,14 @@ class Article {
$this->viewUpdates();
wfProfileOut( __METHOD__ );
}
protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) {
global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
# Display redirect
$imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
if( $overwriteSubtitle ) {
$wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
}
@ -943,7 +943,7 @@ class Article {
$wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
'<span class="redirectText">'.$link.'</span>' );
}
function addTrackbacks() {
@ -1451,7 +1451,7 @@ class Article {
# Update page
$ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) );
if( !$ok ) {
@ -1523,7 +1523,7 @@ class Article {
# Update the page record with revision data
$this->updateRevisionOn( $dbw, $revision, 0 );
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
if( !( $flags & EDIT_SUPPRESS_RC ) ) {
@ -1835,17 +1835,13 @@ class Article {
}
$comment = $wgContLang->ucfirst( wfMsgForContent( $comment_type, $this->mTitle->getPrefixedText() ) );
# Check if all groups that have required right to edit also can protect pages
# Only restrictions with the 'protect' right can cascade...
# Otherwise, people who cannot normally protect can "protect" pages via transclusion
foreach( $limit as $action => $restrictions ) {
# 'sysop' is checked as 'protect', so it is always allowed
if ($cascade && ( $restrictions != 'sysop' ) ){
foreach( $wgGroupPermissions as $group => $rights ){
if( isset( $rights[$restrictions] ) && $rights[$restrictions] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){
$cascade = false;
break( 2 );
}
}
foreach( $limit as $action => $restriction ) {
# FIXME: can $restriction be an array or what? (same as fixme above)
if( $restriction != 'protect' && $restriction != 'sysop' ) {
$cascade = false;
break;
}
}
@ -1888,16 +1884,17 @@ class Article {
'page_latest' => $nullRevId
), array( /* WHERE */
'page_id' => $id
), __METHOD__
), 'Article::protect'
);
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
# Update the protection log
$log = new LogPage( 'protect' );
if( $protect ) {
$log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
$log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle,
trim( $reason . " [$updated]$cascade_description$expiry_description" ) );
} else {
$log->addEntry( 'unprotect', $this->mTitle, $reason );
}
@ -2251,7 +2248,7 @@ class Article {
function doDelete( $reason, $suppress = false ) {
global $wgOut, $wgUser;
wfDebug( __METHOD__."\n" );
$id = $this->getId();
if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
@ -2523,14 +2520,14 @@ class Article {
if( empty( $summary ) ){
$summary = wfMsgForContent( 'revertpage' );
}
# Allow the custom summary to use the same args as the default message
$args = array(
$target->getUserText(), $from, $s->rev_id,
$wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
$current->getId(), $wgLang->timeanddate($current->getTimestamp())
);
$summary = wfMsgReplaceArgs( $summary, $args );
$summary = wfMsgReplaceArgs( $summary, $args );
# Save
$flags = EDIT_UPDATE;
@ -2618,7 +2615,7 @@ class Article {
. $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
$wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
$wgOut->returnToMain( false, $this->mTitle );
if( !$wgRequest->getBool( 'hidediff', false ) ) {
$de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
$de->showDiff( '', '' );
@ -2990,7 +2987,7 @@ class Article {
$revision->insertOn( $dbw );
$this->updateRevisionOn( $dbw, $revision );
$dbw->commit();
wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
wfProfileOut( __METHOD__ );

View file

@ -91,7 +91,8 @@ class ProtectionForm {
global $wgRequest, $wgOut;
if( $wgRequest->wasPosted() ) {
if( $this->save() ) {
$q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
$article = new Article( $this->mTitle );
$q = $article->isRedirect() ? 'redirect=no' : '';
$wgOut->redirect( $this->mTitle->getFullUrl( $q ) );
}
} else {
@ -189,10 +190,17 @@ class ProtectionForm {
}
# NOTE : verification of cascading protection in semi-protection mode
# is in Article::updateRestriction()
# They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
# to a semi-protected page.
global $wgGroupPermissions;
if( $this->mTitle->exists() ){
$edit_restriction = $this->mRestrictions['edit'];
if ($this->mCascade && ($edit_restriction != 'protect') &&
!(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) )
$this->mCascade = false;
if ($this->mTitle->exists()) {
$ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry );
} else {
$ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry );
@ -371,15 +379,7 @@ class ProtectionForm {
$script = 'var wgCascadeableLevels=';
$CascadeableLevels = array();
foreach( $wgRestrictionLevels as $key ) {
$canCascade = true;
$check = $key == 'sysop' ? 'protect' : $key;
foreach( $wgGroupPermissions as $group => $rights ){
if( isset( $rights[$check] ) && $rights[$check] && !( isset( $rights['protect'] ) && $rights['protect'] ) ){
$canCascade = false;
break;
}
}
if( $key != '' && $canCascade ) {
if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
$CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
}
}

View file

@ -1219,10 +1219,15 @@ class Title {
$right = 'protect';
}
if( '' != $right && !$user->isAllowed( $right ) ) {
// Users with 'editprotected' permission can edit protected
// pages if protection is not with cascading option turned on.
if( $action=='edit' && $user->isAllowed( 'editprotected' ) && !$this->areRestrictionsCascading() ) {
// Nothing, user can edit!
//Users with 'editprotected' permission can edit protected pages
if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
//Users with 'editprotected' permission cannot edit protected pages
//with cascading option turned on.
if($this->mCascadeRestriction) {
$errors[] = array( 'protectedpagetext', $right );
} else {
//Nothing, user can edit!
}
} else {
$errors[] = array( 'protectedpagetext', $right );
}
@ -1621,7 +1626,7 @@ class Title {
wfProfileIn( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDb( DB_SLAVE );
if ( $this->getNamespace() == NS_IMAGE ) {
$tables = array ('imagelinks', 'page_restrictions');
@ -1922,7 +1927,7 @@ class Title {
if ($this->mLatestID !== false)
return $this->mLatestID;
$db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
$db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
return $this->mLatestID = $db->selectField( 'revision',
"max(rev_id)",
array('rev_page' => $this->getArticleID($flags)),