Cleanup Title::getTouched()
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 9 Dec 2008 22:03:41 +0000 (22:03 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 9 Dec 2008 22:03:41 +0000 (22:03 +0000)
includes/Article.php
includes/Title.php

index dcb58db..bb1d7a0 100644 (file)
@@ -369,6 +369,7 @@ 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 9e52e5a..2c1c01c 100644 (file)
@@ -69,6 +69,7 @@ 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>
        //@}
 
 
@@ -3135,13 +3136,15 @@ class Title {
 
        /**
         * Get the last touched timestamp
-        * @param Database $db, optional db
         * @return \type{\string} Last touched timestamp
         */
-       public function getTouched( $db = NULL ) {
-               $db = isset($db) ? $db : wfGetDB( DB_SLAVE );
-               $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
-               return $touched;
+       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;
        }
 
        /**