r44365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44364‎ | r44365 | r44366 >
Date:22:03, 9 December 2008
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Cleanup Title::getTouched()
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -369,6 +369,7 @@
370370 $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
371371
372372 $this->mTitle->mArticleID = $data->page_id;
 373+ $this->mTitle->mTouched = wfTimestamp( TS_MW, $data->page_touched );
373374
374375 # Old-fashioned restrictions.
375376 $this->mTitle->loadRestrictions( $data->page_restrictions );
Index: trunk/phase3/includes/Title.php
@@ -69,6 +69,7 @@
7070 var $mLength = -1; ///< The page length, 0 for special pages
7171 var $mRedirect = null; ///< Is the article at this title a redirect?
7272 var $mNotificationTimestamp = array(); ///< Associative array of user ID -> timestamp/false
 73+ var $mTouched = null; // <last cache date>
7374 //@}
7475
7576
@@ -3135,13 +3136,15 @@
31363137
31373138 /**
31383139 * Get the last touched timestamp
3139 - * @param Database $db, optional db
31403140 * @return \type{\string} Last touched timestamp
31413141 */
3142 - public function getTouched( $db = NULL ) {
3143 - $db = isset($db) ? $db : wfGetDB( DB_SLAVE );
3144 - $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
3145 - return $touched;
 3142+ public function getTouched() {
 3143+ if( !is_null($this->mTouched) ) {
 3144+ return wfTimestamp( TS_MW, $this->mTouched );
 3145+ }
 3146+ $dbr = wfGetDB( DB_SLAVE );
 3147+ $this->mTouched = $dbr->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
 3148+ return $this->mTouched;
31463149 }
31473150
31483151 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r44438Revert r44365 "Cleanup Title::getTouched()"...brion00:42, 11 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   00:43, 11 December 2008

Reverted in r44438.

Rather than a cleanup, this rev seems to be adding a per-Title-object cache of page_touched. I'm a little leery of adding extra caches like this, particularly since it's not clear that it'll get consistently updated.

Status & tagging log