Index: trunk/phase3/includes/Title.php |
— | — | @@ -45,28 +45,29 @@ |
46 | 46 | * @private |
47 | 47 | */ |
48 | 48 | |
49 | | - var $mTextform = ''; # Text form (spaces not underscores) of the main part |
50 | | - var $mUrlform = ''; # URL-encoded form of the main part |
51 | | - var $mDbkeyform = ''; # Main part with underscores |
| 49 | + var $mTextform = ''; # Text form (spaces not underscores) of the main part |
| 50 | + var $mUrlform = ''; # URL-encoded form of the main part |
| 51 | + var $mDbkeyform = ''; # Main part with underscores |
52 | 52 | var $mUserCaseDBKey; # DB key with the initial letter in the case specified by the user |
53 | 53 | var $mNamespace = NS_MAIN; # Namespace index, i.e. one of the NS_xxxx constants |
54 | | - var $mInterwiki = ''; # Interwiki prefix (or null string) |
55 | | - var $mFragment; # Title fragment (i.e. the bit after the #) |
| 54 | + var $mInterwiki = ''; # Interwiki prefix (or null string) |
| 55 | + var $mFragment; # Title fragment (i.e. the bit after the #) |
56 | 56 | var $mArticleID = -1; # Article ID, fetched from the link cache on demand |
57 | 57 | var $mLatestID = false; # ID of most recent revision |
58 | 58 | var $mRestrictions = array(); # Array of groups allowed to edit this article |
59 | 59 | var $mOldRestrictions = false; |
60 | | - var $mCascadeRestriction; # Cascade restrictions on this page to included templates and images? |
61 | | - var $mRestrictionsExpiry; # When do the restrictions on this page expire? |
| 60 | + var $mCascadeRestriction; # Cascade restrictions on this page to included templates and images? |
| 61 | + var $mRestrictionsExpiry; # When do the restrictions on this page expire? |
62 | 62 | var $mHasCascadingRestrictions; # Are cascading restrictions in effect on this page? |
63 | 63 | var $mCascadeRestrictionSources; # Where are the cascading restrictions coming from on this page? |
64 | 64 | var $mRestrictionsLoaded = false; # Boolean for initialisation on demand |
65 | | - var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand |
| 65 | + var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand |
| 66 | + |
66 | 67 | # Don't change the following default, NS_MAIN is hardcoded in several |
67 | 68 | # places. See bug 696. |
68 | 69 | var $mDefaultNamespace = NS_MAIN; # Namespace index when there is no namespace |
69 | | - # Zero except in {{transclusion}} tags |
70 | | - var $mWatched = null; # Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() |
| 70 | + # Zero except in {{transclusion}} tags |
| 71 | + var $mWatched = null; # Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() |
71 | 72 | var $mLength = -1; # The page length, 0 for special pages |
72 | 73 | var $mRedirect = null; # Is the article at this title a redirect? |
73 | 74 | /**#@-*/ |
— | — | @@ -1339,15 +1340,28 @@ |
1340 | 1341 | return false; |
1341 | 1342 | } |
1342 | 1343 | |
| 1344 | + wfDebug( wfBacktrace() ); |
| 1345 | + |
| 1346 | + // Cache to avoid multiple database queries for the same title |
| 1347 | + if ( isset($this->mProtections) ) { |
| 1348 | + return $this->mProtections; |
| 1349 | + } |
| 1350 | + |
| 1351 | + $conds = array( |
| 1352 | + 'pt_namespace' => $this->getNamespace(), |
| 1353 | + 'pt_title' => $this->getDBkey() |
| 1354 | + ); |
| 1355 | + |
1343 | 1356 | $dbr = wfGetDB( DB_SLAVE ); |
1344 | | - $res = $dbr->select( 'protected_titles', '*', |
1345 | | - array ('pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey()) ); |
| 1357 | + $res = $dbr->select( 'protected_titles', '*', $conds, __METHOD__ ); |
1346 | 1358 | |
1347 | 1359 | if ($row = $dbr->fetchRow( $res )) { |
1348 | | - return $row; |
| 1360 | + $this->mProtections = $row; |
1349 | 1361 | } else { |
1350 | | - return false; |
| 1362 | + $this->mProtections = false; |
1351 | 1363 | } |
| 1364 | + |
| 1365 | + return $this->mProtections; |
1352 | 1366 | } |
1353 | 1367 | |
1354 | 1368 | public function updateTitleProtection( $create_perm, $reason, $expiry ) { |
— | — | @@ -1879,19 +1893,30 @@ |
1880 | 1894 | * @return int the number of archived revisions |
1881 | 1895 | */ |
1882 | 1896 | public function isDeleted() { |
1883 | | - $fname = 'Title::isDeleted'; |
1884 | 1897 | if ( $this->getNamespace() < 0 ) { |
1885 | | - $n = 0; |
1886 | | - } else { |
1887 | | - $dbr = wfGetDB( DB_SLAVE ); |
1888 | | - $n = $dbr->selectField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(), |
1889 | | - 'ar_title' => $this->getDBkey() ), $fname ); |
1890 | | - if( $this->getNamespace() == NS_IMAGE ) { |
1891 | | - $n += $dbr->selectField( 'filearchive', 'COUNT(*)', |
1892 | | - array( 'fa_name' => $this->getDBkey() ), $fname ); |
1893 | | - } |
| 1898 | + return 0; |
1894 | 1899 | } |
1895 | | - return (int)$n; |
| 1900 | + |
| 1901 | + // Cache to avoid multiple queries for the same title |
| 1902 | + if ( isset($this->mIsDeleted) ) { |
| 1903 | + return $this->mIsDeleted; |
| 1904 | + } |
| 1905 | + |
| 1906 | + $dbr = wfGetDB( DB_SLAVE ); |
| 1907 | + $aConds = array( |
| 1908 | + 'ar_namespace' => $this->getNamespace(), |
| 1909 | + 'ar_title' => $this->getDBkey() |
| 1910 | + ); |
| 1911 | + $n = $dbr->selectField( 'archive', 'COUNT(*)', $aConds, __METHOD__ ); |
| 1912 | + |
| 1913 | + if ( $this->getNamespace() == NS_IMAGE ) { |
| 1914 | + $faConds = array( 'fa_name' => $this->getDBkey() ); |
| 1915 | + $n += $dbr->selectField( 'filearchive', 'COUNT(*)', $faConds , __METHOD__ ); |
| 1916 | + } |
| 1917 | + |
| 1918 | + $this->mIsDeleted = (int) $n; |
| 1919 | + |
| 1920 | + return $this->mIsDeleted; |
1896 | 1921 | } |
1897 | 1922 | |
1898 | 1923 | /** |