r65500 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65499‎ | r65500 | r65501 >
Date:00:23, 24 April 2010
Author:mah
Status:resolved (Comments)
Tags:
Comment:
cache the result of getTitleProtection to make testing easier
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -63,6 +63,7 @@
6464 var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page?
6565 var $mRestrictionsLoaded = false; ///< Boolean for initialisation on demand
6666 var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand
 67+ var $mTitleProtection; ///< Cached value of getTitleProtection
6768 # Don't change the following default, NS_MAIN is hardcoded in several
6869 # places. See bug 696.
6970 var $mDefaultNamespace = NS_MAIN; ///< Namespace index when there is no namespace
@@ -1481,16 +1482,16 @@
14821483 return false;
14831484 }
14841485
1485 - $dbr = wfGetDB( DB_SLAVE );
1486 - $res = $dbr->select( 'protected_titles', '*',
1487 - array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ),
1488 - __METHOD__ );
 1486+ if ( !isset( $this->mTitleProtection ) ) {
 1487+ $dbr = wfGetDB( DB_SLAVE );
 1488+ $res = $dbr->select( 'protected_titles', '*',
 1489+ array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ),
 1490+ __METHOD__ );
14891491
1490 - if ($row = $dbr->fetchRow( $res )) {
1491 - return $row;
1492 - } else {
1493 - return false;
 1492+ // fetchRow returns false if there are no rows.
 1493+ $this->mTitleProtection = $dbr->fetchRow( $res );
14941494 }
 1495+ return $this->mTitleProtection;
14951496 }
14961497
14971498 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r76242Follow up r65500 : invalidate Title protection cache.hashar11:54, 7 November 2010

Comments

#Comment by Hashar (talk | contribs)   11:55, 7 November 2010

Does not invalidate cache when field in protected_titles is deleted / updated. r76242 should take care of it.

Status & tagging log