Index: trunk/phase3/includes/Title.php |
— | — | @@ -63,7 +63,6 @@ |
64 | 64 | var $mFragment; // /< Title fragment (i.e. the bit after the #) |
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 | | - var $mCounter = -1; // /< Number of times this page has been viewed (-1 means "not loaded") |
68 | 67 | private $mEstimateRevisions; // /< Estimated number of revisions; null of not loaded |
69 | 68 | var $mRestrictions = array(); // /< Array of groups allowed to edit this article |
70 | 69 | var $mOldRestrictions = false; |
— | — | @@ -274,14 +273,11 @@ |
275 | 274 | $this->mRedirect = (bool)$row->page_is_redirect; |
276 | 275 | if ( isset( $row->page_latest ) ) |
277 | 276 | $this->mLatestID = (int)$row->page_latest; |
278 | | - if ( isset( $row->page_counter ) ) |
279 | | - $this->mCounter = (int)$row->page_counter; |
280 | 277 | } else { // page not found |
281 | 278 | $this->mArticleID = 0; |
282 | 279 | $this->mLength = 0; |
283 | 280 | $this->mRedirect = false; |
284 | 281 | $this->mLatestID = 0; |
285 | | - $this->mCounter = 0; |
286 | 282 | } |
287 | 283 | } |
288 | 284 | |
— | — | @@ -2758,28 +2754,6 @@ |
2759 | 2755 | } |
2760 | 2756 | |
2761 | 2757 | /** |
2762 | | - * Get the number of views of this page |
2763 | | - * |
2764 | | - * @return int The view count for the page |
2765 | | - */ |
2766 | | - public function getCount() { |
2767 | | - if ( $this->mCounter == -1 ) { |
2768 | | - if ( $this->exists() ) { |
2769 | | - $dbr = wfGetDB( DB_SLAVE ); |
2770 | | - $this->mCounter = $dbr->selectField( 'page', |
2771 | | - 'page_counter', |
2772 | | - array( 'page_id' => $this->getArticleID() ), |
2773 | | - __METHOD__ |
2774 | | - ); |
2775 | | - } else { |
2776 | | - $this->mCounter = 0; |
2777 | | - } |
2778 | | - } |
2779 | | - |
2780 | | - return $this->mCounter; |
2781 | | - } |
2782 | | - |
2783 | | - /** |
2784 | 2758 | * Get the article ID for this Title from the link cache, |
2785 | 2759 | * adding it if necessary |
2786 | 2760 | * |
— | — | @@ -2891,7 +2865,6 @@ |
2892 | 2866 | $this->mRedirect = null; |
2893 | 2867 | $this->mLength = -1; |
2894 | 2868 | $this->mLatestID = false; |
2895 | | - $this->mCounter = -1; |
2896 | 2869 | $this->mEstimateRevisions = null; |
2897 | 2870 | } |
2898 | 2871 | |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -318,7 +318,7 @@ |
319 | 319 | if ( $out->isArticle() && $title->exists() ) { |
320 | 320 | if ( $this->isRevisionCurrent() ) { |
321 | 321 | if ( !$wgDisableCounters ) { |
322 | | - $viewcount = $title->getCount(); |
| 322 | + $viewcount = $this->getWikiPage()->getCount(); |
323 | 323 | if ( $viewcount ) { |
324 | 324 | $tpl->set( 'viewcount', $this->msg( 'viewcount' )->numParams( $viewcount )->parse() ); |
325 | 325 | } |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | } |
340 | 340 | |
341 | 341 | if ( $wgMaxCredits != 0 ) { |
342 | | - $tpl->set( 'credits', Action::factory( 'credits', WikiPage::factory( $title ), |
| 342 | + $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(), |
343 | 343 | $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); |
344 | 344 | } else { |
345 | 345 | $tpl->set( 'lastmod', $this->lastModified() ); |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -48,6 +48,11 @@ |
49 | 49 | protected $mTouched = '19700101000000'; |
50 | 50 | |
51 | 51 | /** |
| 52 | + * @var int|null |
| 53 | + */ |
| 54 | + protected $mCounter = null; |
| 55 | + |
| 56 | + /** |
52 | 57 | * Constructor and clear the article |
53 | 58 | * @param $title Title Reference to a Title object. |
54 | 59 | */ |
— | — | @@ -246,6 +251,7 @@ |
247 | 252 | public function clear() { |
248 | 253 | $this->mDataLoaded = false; |
249 | 254 | |
| 255 | + $this->mCounter = null; |
250 | 256 | $this->mRedirectTarget = null; # Title object if set |
251 | 257 | $this->mLastRevision = null; # Latest revision |
252 | 258 | $this->mTouched = '19700101000000'; |
— | — | @@ -385,6 +391,7 @@ |
386 | 392 | # Old-fashioned restrictions |
387 | 393 | $this->mTitle->loadRestrictions( $data->page_restrictions ); |
388 | 394 | |
| 395 | + $this->mCounter = intval( $data->page_counter ); |
389 | 396 | $this->mTouched = wfTimestamp( TS_MW, $data->page_touched ); |
390 | 397 | $this->mIsRedirect = intval( $data->page_is_redirect ); |
391 | 398 | $this->mLatest = intval( $data->page_latest ); |
— | — | @@ -424,12 +431,14 @@ |
425 | 432 | } |
426 | 433 | |
427 | 434 | /** |
428 | | - * Get the number of views of this page |
429 | | - * |
430 | 435 | * @return int The view count for the page |
431 | 436 | */ |
432 | 437 | public function getCount() { |
433 | | - return $this->mTitle->getCount(); |
| 438 | + if ( !$this->mDataLoaded ) { |
| 439 | + $this->loadPageData(); |
| 440 | + } |
| 441 | + |
| 442 | + return $this->mCounter; |
434 | 443 | } |
435 | 444 | |
436 | 445 | /** |