Index: trunk/phase3/includes/Title.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | var $mArticleID = -1; // /< Article ID, fetched from the link cache on demand |
66 | 66 | var $mLatestID = false; // /< ID of most recent revision |
67 | 67 | var $mCounter = -1; // /< Number of times this page has been viewed (-1 means "not loaded") |
| 68 | + private $mTouched; // /< Timestamp of the last time this page was touched |
68 | 69 | private $mIsNew; // /< Whether this is a "new page" (i.e. it has only one revision) |
69 | 70 | private $mEstimateRevisions; // /< Estimated number of revisions; null of not loaded |
70 | 71 | var $mRestrictions = array(); // /< Array of groups allowed to edit this article |
— | — | @@ -234,6 +235,7 @@ |
235 | 236 | array( |
236 | 237 | 'page_namespace', 'page_title', 'page_id', |
237 | 238 | 'page_len', 'page_is_redirect', 'page_latest', |
| 239 | + 'page_counter', 'page_touched', 'page_is_new', |
238 | 240 | ), |
239 | 241 | array( 'page_id' => $ids ), |
240 | 242 | __METHOD__ |
— | — | @@ -277,6 +279,8 @@ |
278 | 280 | $this->mLatestID = (int)$row->page_latest; |
279 | 281 | if ( isset( $row->page_counter ) ) |
280 | 282 | $this->mCounter = (int)$row->page_counter; |
| 283 | + if ( isset( $row->page_touched ) ) |
| 284 | + $this->mTouched = $row->page_touched; |
281 | 285 | if ( isset( $row->page_is_new ) ) |
282 | 286 | $this->mIsNew = (bool)$row->page_is_new; |
283 | 287 | } else { // page not found |
— | — | @@ -285,6 +289,8 @@ |
286 | 290 | $this->mRedirect = false; |
287 | 291 | $this->mLatestID = 0; |
288 | 292 | $this->mCounter = 0; |
| 293 | + $this->mTouched = '19700101000000'; |
| 294 | + $this->mIsNew = false; |
289 | 295 | } |
290 | 296 | } |
291 | 297 | |
— | — | @@ -2787,6 +2793,28 @@ |
2788 | 2794 | } |
2789 | 2795 | |
2790 | 2796 | /** |
| 2797 | + * Get the last touched timestamp |
| 2798 | + * |
| 2799 | + * @return String last-touched timestamp |
| 2800 | + */ |
| 2801 | + public function getTouched() { |
| 2802 | + if ( $this->mTouched == null ) { |
| 2803 | + if ( $this->exists() ) { |
| 2804 | + $dbr = wfGetDB( DB_SLAVE ); |
| 2805 | + $this->mTouched = $dbr->selectField( 'page', |
| 2806 | + 'page_touched', |
| 2807 | + array( 'page_id' => $this->getArticleID() ), |
| 2808 | + __METHOD__ |
| 2809 | + ); |
| 2810 | + } else { |
| 2811 | + $this->mTouched = '19700101000000'; |
| 2812 | + } |
| 2813 | + } |
| 2814 | + |
| 2815 | + return $this->mTouched; |
| 2816 | + } |
| 2817 | + |
| 2818 | + /** |
2791 | 2819 | * Check if this is a new page (i.e. it has only one revision) |
2792 | 2820 | * |
2793 | 2821 | * @return bool |
— | — | @@ -4281,18 +4309,6 @@ |
4282 | 4310 | } |
4283 | 4311 | |
4284 | 4312 | /** |
4285 | | - * Get the last touched timestamp |
4286 | | - * |
4287 | | - * @param $db DatabaseBase: optional db |
4288 | | - * @return String last-touched timestamp |
4289 | | - */ |
4290 | | - public function getTouched( $db = null ) { |
4291 | | - $db = isset( $db ) ? $db : wfGetDB( DB_SLAVE ); |
4292 | | - $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ ); |
4293 | | - return $touched; |
4294 | | - } |
4295 | | - |
4296 | | - /** |
4297 | 4313 | * Get the timestamp when this page was updated since the user last saw it. |
4298 | 4314 | * |
4299 | 4315 | * @param $user User |