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 $mIsNew; // /< Whether this is a "new page" (i.e. it has only one revision) |
68 | 69 | private $mEstimateRevisions; // /< Estimated number of revisions; null of not loaded |
69 | 70 | var $mRestrictions = array(); // /< Array of groups allowed to edit this article |
70 | 71 | var $mOldRestrictions = false; |
— | — | @@ -276,6 +277,8 @@ |
277 | 278 | $this->mLatestID = (int)$row->page_latest; |
278 | 279 | if ( isset( $row->page_counter ) ) |
279 | 280 | $this->mCounter = (int)$row->page_counter; |
| 281 | + if ( isset( $row->page_is_new ) ) |
| 282 | + $this->mIsNew = (bool)$row->page_is_new; |
280 | 283 | } else { // page not found |
281 | 284 | $this->mArticleID = 0; |
282 | 285 | $this->mLength = 0; |
— | — | @@ -2784,6 +2787,27 @@ |
2785 | 2788 | } |
2786 | 2789 | |
2787 | 2790 | /** |
| 2791 | + * Check if this is a new page (i.e. it has only one revision) |
| 2792 | + * |
| 2793 | + * @return bool |
| 2794 | + */ |
| 2795 | + public function isNewPage() { |
| 2796 | + if ( $this->mIsNew === null ) { |
| 2797 | + if ( $this->exists() ) { |
| 2798 | + $dbr = wfGetDB( DB_SLAVE ); |
| 2799 | + $this->mIsNew = (bool)$dbr->selectField( 'page', |
| 2800 | + 'page_is_new', |
| 2801 | + array( 'page_id' => $this->getArticleID() ), |
| 2802 | + __METHOD__ |
| 2803 | + ); |
| 2804 | + } else { |
| 2805 | + $this->mIsNew = false; |
| 2806 | + } |
| 2807 | + } |
| 2808 | + return $this->mIsNew; |
| 2809 | + } |
| 2810 | + |
| 2811 | + /** |
2788 | 2812 | * Get the article ID for this Title from the link cache, |
2789 | 2813 | * adding it if necessary |
2790 | 2814 | * |
— | — | @@ -3992,16 +4016,6 @@ |
3993 | 4017 | } |
3994 | 4018 | |
3995 | 4019 | /** |
3996 | | - * Check if this is a new page |
3997 | | - * |
3998 | | - * @return bool |
3999 | | - */ |
4000 | | - public function isNewPage() { |
4001 | | - $dbr = wfGetDB( DB_SLAVE ); |
4002 | | - return (bool)$dbr->selectField( 'page', 'page_is_new', $this->pageCond(), __METHOD__ ); |
4003 | | - } |
4004 | | - |
4005 | | - /** |
4006 | 4020 | * Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit |
4007 | 4021 | * |
4008 | 4022 | * @return bool |