Index: trunk/phase3/includes/Title.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page? |
74 | 74 | var $mRestrictionsLoaded = false; ///< Boolean for initialisation on demand |
75 | 75 | var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand |
76 | | - var $mTitleProtection; ///< Cached value of getTitleProtection |
| 76 | + var $mTitleProtection; ///< Cached value for getTitleProtection (create protection) |
77 | 77 | # Don't change the following default, NS_MAIN is hardcoded in several |
78 | 78 | # places. See bug 696. |
79 | 79 | var $mDefaultNamespace = NS_MAIN; // /< Namespace index when there is no namespace |
— | — | @@ -1629,6 +1629,7 @@ |
1630 | 1630 | |
1631 | 1631 | /** |
1632 | 1632 | * Is this title subject to title protection? |
| 1633 | + * Title protection is the one applied against creation of such title. |
1633 | 1634 | * |
1634 | 1635 | * @return Mixed An associative array representing any existent title |
1635 | 1636 | * protection, or false if there's none. |
— | — | @@ -1656,10 +1657,6 @@ |
1657 | 1658 | return $this->mTitleProtection; |
1658 | 1659 | } |
1659 | 1660 | |
1660 | | - private function invalidateTitleProtectionCache() { |
1661 | | - unset( $this->mTitleProtection ); |
1662 | | - } |
1663 | | - |
1664 | 1661 | /** |
1665 | 1662 | * Update the title protection status |
1666 | 1663 | * |
— | — | @@ -1693,8 +1690,7 @@ |
1694 | 1691 | |
1695 | 1692 | # Update protection table |
1696 | 1693 | if ( $create_perm != '' ) { |
1697 | | - $dbw->replace( 'protected_titles', array( array( 'pt_namespace', 'pt_title' ) ), |
1698 | | - array( |
| 1694 | + $this->mTitleProtection = array( |
1699 | 1695 | 'pt_namespace' => $namespace, |
1700 | 1696 | 'pt_title' => $title, |
1701 | 1697 | 'pt_create_perm' => $create_perm, |
— | — | @@ -1702,13 +1698,14 @@ |
1703 | 1699 | 'pt_expiry' => $encodedExpiry, |
1704 | 1700 | 'pt_user' => $wgUser->getId(), |
1705 | 1701 | 'pt_reason' => $reason, |
1706 | | - ), __METHOD__ |
1707 | | - ); |
| 1702 | + ); |
| 1703 | + $dbw->replace( 'protected_titles', array( array( 'pt_namespace', 'pt_title' ) ), |
| 1704 | + $this->mTitleProtection, __METHOD__ ); |
1708 | 1705 | } else { |
1709 | 1706 | $dbw->delete( 'protected_titles', array( 'pt_namespace' => $namespace, |
1710 | 1707 | 'pt_title' => $title ), __METHOD__ ); |
| 1708 | + $this->mTitleProtection = false; |
1711 | 1709 | } |
1712 | | - $this->invalidateTitleProtectionCache(); |
1713 | 1710 | |
1714 | 1711 | # Update the protection log |
1715 | 1712 | if ( $dbw->affectedRows() ) { |
— | — | @@ -1736,7 +1733,7 @@ |
1737 | 1734 | array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ), |
1738 | 1735 | __METHOD__ |
1739 | 1736 | ); |
1740 | | - $this->invalidateTitleProtectionCache(); |
| 1737 | + $this->mTitleProtection = false; |
1741 | 1738 | } |
1742 | 1739 | |
1743 | 1740 | /** |
— | — | @@ -2110,7 +2107,6 @@ |
2111 | 2108 | } |
2112 | 2109 | if ( $purgeExpired ) { |
2113 | 2110 | Title::purgeExpiredRestrictions(); |
2114 | | - $this->invalidateTitleProtectionCache(); |
2115 | 2111 | } |
2116 | 2112 | |
2117 | 2113 | wfProfileOut( __METHOD__ ); |
— | — | @@ -2157,13 +2153,13 @@ |
2158 | 2154 | |
2159 | 2155 | /** |
2160 | 2156 | * Compiles list of active page restrictions from both page table (pre 1.10) |
2161 | | - * and page_restrictions table |
| 2157 | + * and page_restrictions table for this existing page |
2162 | 2158 | * |
2163 | 2159 | * @param $rows array of db result objects |
2164 | 2160 | * @param $oldFashionedRestrictions string comma-separated list of page |
2165 | 2161 | * restrictions from page table (pre 1.10) |
2166 | 2162 | */ |
2167 | | - public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) { |
| 2163 | + private function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) { |
2168 | 2164 | $dbr = wfGetDB( DB_SLAVE ); |
2169 | 2165 | |
2170 | 2166 | $restrictionTypes = $this->getRestrictionTypes(); |
— | — | @@ -2230,7 +2226,6 @@ |
2231 | 2227 | |
2232 | 2228 | if ( $purgeExpired ) { |
2233 | 2229 | Title::purgeExpiredRestrictions(); |
2234 | | - $this->invalidateTitleProtectionCache(); |
2235 | 2230 | } |
2236 | 2231 | } |
2237 | 2232 | |
— | — | @@ -2265,7 +2260,7 @@ |
2266 | 2261 | $this->mRestrictions['create'] = explode( ',', trim( $title_protection['pt_create_perm'] ) ); |
2267 | 2262 | } else { // Get rid of the old restrictions |
2268 | 2263 | Title::purgeExpiredRestrictions(); |
2269 | | - $this->invalidateTitleProtectionCache(); |
| 2264 | + $this->mTitleProtection = false; |
2270 | 2265 | } |
2271 | 2266 | } else { |
2272 | 2267 | $this->mRestrictionsExpiry['create'] = Block::decodeExpiry( '' ); |