Index: trunk/phase3/includes/Title.php |
— | — | @@ -1398,6 +1398,11 @@ |
1399 | 1399 | if ( $this->getNamespace() < 0 ) { |
1400 | 1400 | return false; |
1401 | 1401 | } |
| 1402 | + |
| 1403 | + // Can't protect pages that exist. |
| 1404 | + if ($this->exists()) { |
| 1405 | + return false; |
| 1406 | + } |
1402 | 1407 | |
1403 | 1408 | $dbr = wfGetDB( DB_SLAVE ); |
1404 | 1409 | $res = $dbr->select( 'protected_titles', '*', |
— | — | @@ -1857,7 +1862,18 @@ |
1858 | 1863 | * Loads a string into mRestrictions array |
1859 | 1864 | * @param $res \type{Resource} restrictions as an SQL result. |
1860 | 1865 | */ |
1861 | | - private function loadRestrictionsFromRow( $res, $oldFashionedRestrictions = NULL ) { |
| 1866 | + private function loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions = NULL ) { |
| 1867 | + $rows = array(); |
| 1868 | + $dbr = wfGetDB( DB_SLAVE ); |
| 1869 | + |
| 1870 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 1871 | + $rows[] = $row; |
| 1872 | + } |
| 1873 | + |
| 1874 | + $this->loadRestrictionsFromRows( $rows, $oldFashionedRestrictions ); |
| 1875 | + } |
| 1876 | + |
| 1877 | + public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = NULL ) { |
1862 | 1878 | global $wgRestrictionTypes; |
1863 | 1879 | $dbr = wfGetDB( DB_SLAVE ); |
1864 | 1880 | |
— | — | @@ -1892,12 +1908,12 @@ |
1893 | 1909 | |
1894 | 1910 | } |
1895 | 1911 | |
1896 | | - if( $dbr->numRows( $res ) ) { |
| 1912 | + if( count($rows) ) { |
1897 | 1913 | # Current system - load second to make them override. |
1898 | 1914 | $now = wfTimestampNow(); |
1899 | 1915 | $purgeExpired = false; |
1900 | 1916 | |
1901 | | - foreach( $res as $row ) { |
| 1917 | + foreach( $rows as $row ) { |
1902 | 1918 | # Cycle through all the restrictions. |
1903 | 1919 | |
1904 | 1920 | // Don't take care of restrictions types that aren't in $wgRestrictionTypes |
— | — | @@ -1939,7 +1955,7 @@ |
1940 | 1956 | $res = $dbr->select( 'page_restrictions', '*', |
1941 | 1957 | array ( 'pr_page' => $this->getArticleId() ), __METHOD__ ); |
1942 | 1958 | |
1943 | | - $this->loadRestrictionsFromRow( $res, $oldFashionedRestrictions ); |
| 1959 | + $this->loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions ); |
1944 | 1960 | } else { |
1945 | 1961 | $title_protection = $this->getTitleProtection(); |
1946 | 1962 | |