r79759 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79758‎ | r79759 | r79760 >
Date:21:26, 6 January 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Address my r76242 fixme.
Remove invalidateTitleProtectionCache().
Set $mTitleProtection to the proper value when we change it instead of forcing a reload via the protected_titles table.
Make Title::loadRestrictionsFromRows() private since it is only called by the private loadRestrictionsFromResultWrapper() and nobody should be fiddling with such title internals anyway (follow up to r54527).
Removed the invalidateTitleProtectionCache() from getCascadeProtectionSources() since that function only deals with titles which do exist. There's nothing to invalidate there.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -72,7 +72,7 @@
7373 var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page?
7474 var $mRestrictionsLoaded = false; ///< Boolean for initialisation on demand
7575 var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand
76 - var $mTitleProtection; ///< Cached value of getTitleProtection
 76+ var $mTitleProtection; ///< Cached value for getTitleProtection (create protection)
7777 # Don't change the following default, NS_MAIN is hardcoded in several
7878 # places. See bug 696.
7979 var $mDefaultNamespace = NS_MAIN; // /< Namespace index when there is no namespace
@@ -1629,6 +1629,7 @@
16301630
16311631 /**
16321632 * Is this title subject to title protection?
 1633+ * Title protection is the one applied against creation of such title.
16331634 *
16341635 * @return Mixed An associative array representing any existent title
16351636 * protection, or false if there's none.
@@ -1656,10 +1657,6 @@
16571658 return $this->mTitleProtection;
16581659 }
16591660
1660 - private function invalidateTitleProtectionCache() {
1661 - unset( $this->mTitleProtection );
1662 - }
1663 -
16641661 /**
16651662 * Update the title protection status
16661663 *
@@ -1693,8 +1690,7 @@
16941691
16951692 # Update protection table
16961693 if ( $create_perm != '' ) {
1697 - $dbw->replace( 'protected_titles', array( array( 'pt_namespace', 'pt_title' ) ),
1698 - array(
 1694+ $this->mTitleProtection = array(
16991695 'pt_namespace' => $namespace,
17001696 'pt_title' => $title,
17011697 'pt_create_perm' => $create_perm,
@@ -1702,13 +1698,14 @@
17031699 'pt_expiry' => $encodedExpiry,
17041700 'pt_user' => $wgUser->getId(),
17051701 'pt_reason' => $reason,
1706 - ), __METHOD__
1707 - );
 1702+ );
 1703+ $dbw->replace( 'protected_titles', array( array( 'pt_namespace', 'pt_title' ) ),
 1704+ $this->mTitleProtection, __METHOD__ );
17081705 } else {
17091706 $dbw->delete( 'protected_titles', array( 'pt_namespace' => $namespace,
17101707 'pt_title' => $title ), __METHOD__ );
 1708+ $this->mTitleProtection = false;
17111709 }
1712 - $this->invalidateTitleProtectionCache();
17131710
17141711 # Update the protection log
17151712 if ( $dbw->affectedRows() ) {
@@ -1736,7 +1733,7 @@
17371734 array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ),
17381735 __METHOD__
17391736 );
1740 - $this->invalidateTitleProtectionCache();
 1737+ $this->mTitleProtection = false;
17411738 }
17421739
17431740 /**
@@ -2110,7 +2107,6 @@
21112108 }
21122109 if ( $purgeExpired ) {
21132110 Title::purgeExpiredRestrictions();
2114 - $this->invalidateTitleProtectionCache();
21152111 }
21162112
21172113 wfProfileOut( __METHOD__ );
@@ -2157,13 +2153,13 @@
21582154
21592155 /**
21602156 * Compiles list of active page restrictions from both page table (pre 1.10)
2161 - * and page_restrictions table
 2157+ * and page_restrictions table for this existing page
21622158 *
21632159 * @param $rows array of db result objects
21642160 * @param $oldFashionedRestrictions string comma-separated list of page
21652161 * restrictions from page table (pre 1.10)
21662162 */
2167 - public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) {
 2163+ private function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) {
21682164 $dbr = wfGetDB( DB_SLAVE );
21692165
21702166 $restrictionTypes = $this->getRestrictionTypes();
@@ -2230,7 +2226,6 @@
22312227
22322228 if ( $purgeExpired ) {
22332229 Title::purgeExpiredRestrictions();
2234 - $this->invalidateTitleProtectionCache();
22352230 }
22362231 }
22372232
@@ -2265,7 +2260,7 @@
22662261 $this->mRestrictions['create'] = explode( ',', trim( $title_protection['pt_create_perm'] ) );
22672262 } else { // Get rid of the old restrictions
22682263 Title::purgeExpiredRestrictions();
2269 - $this->invalidateTitleProtectionCache();
 2264+ $this->mTitleProtection = false;
22702265 }
22712266 } else {
22722267 $this->mRestrictionsExpiry['create'] = Block::decodeExpiry( '' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r79764Follow up r79759. Title::loadRestrictionsFromRows called by LiquidThreadsplatonides22:19, 6 January 2011
r798151.17: MFT r78327, r78560, r79131, r79708, r79713, r79725, r79758, r79759, r79...catrope13:55, 7 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54527* Fail fast on trying to find create restrictions for pages that exist....werdna16:26, 6 August 2009
r76242Follow up r65500 : invalidate Title protection cache.hashar11:54, 7 November 2010

Comments

#Comment by Raymond (talk | contribs)   22:10, 6 January 2011

Seen on Translatewiki:

PHP Fatal error: Call to private method Title::loadRestrictionsFromRows() from context 'Thread' in /www/w/extensions/LiquidThreads/classes/Thread.php on line 672
#Comment by Platonides (talk | contribs)   22:19, 6 January 2011

LiquidThreads. I should have guessed it, being a werdna revision. Fixed in r79764.

Status & tagging log