Revert r44365 "Cleanup Title::getTouched()"
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Dec 2008 00:42:50 +0000 (00:42 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Dec 2008 00:42:50 +0000 (00:42 +0000)
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.

includes/Article.php
includes/Title.php

index 22e1514..15ca8c5 100644 (file)
@@ -369,7 +369,6 @@ class Article {
                        $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
 
                        $this->mTitle->mArticleID = $data->page_id;
-                       $this->mTitle->mTouched = wfTimestamp( TS_MW, $data->page_touched );
 
                        # Old-fashioned restrictions
                        $this->mTitle->loadRestrictions( $data->page_restrictions );
index 2c1c01c..9e52e5a 100644 (file)
@@ -69,7 +69,6 @@ class Title {
        var $mLength = -1;                ///< The page length, 0 for special pages
        var $mRedirect = null;            ///< Is the article at this title a redirect?
        var $mNotificationTimestamp = array(); ///< Associative array of user ID -> timestamp/false
-       var $mTouched = null; // <last cache date>
        //@}
 
 
@@ -3136,15 +3135,13 @@ class Title {
 
        /**
         * Get the last touched timestamp
+        * @param Database $db, optional db
         * @return \type{\string} Last touched timestamp
         */
-       public function getTouched() {
-               if( !is_null($this->mTouched) ) {
-                       return wfTimestamp( TS_MW, $this->mTouched );
-               }
-               $dbr = wfGetDB( DB_SLAVE );
-               $this->mTouched = $dbr->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
-               return $this->mTouched;
+       public function getTouched( $db = NULL ) {
+               $db = isset($db) ? $db : wfGetDB( DB_SLAVE );
+               $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
+               return $touched;
        }
 
        /**