if ( $this->getNamespace() < 0 ) {
return false;
}
+
+ // Can't protect pages that exist.
+ if ($this->exists()) {
+ return false;
+ }
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'protected_titles', '*',
* Loads a string into mRestrictions array
* @param $res \type{Resource} restrictions as an SQL result.
*/
- private function loadRestrictionsFromRow( $res, $oldFashionedRestrictions = NULL ) {
+ private function loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions = NULL ) {
+ $rows = array();
+ $dbr = wfGetDB( DB_SLAVE );
+
+ while( $row = $dbr->fetchObject( $res ) ) {
+ $rows[] = $row;
+ }
+
+ $this->loadRestrictionsFromRows( $rows, $oldFashionedRestrictions );
+ }
+
+ public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = NULL ) {
global $wgRestrictionTypes;
$dbr = wfGetDB( DB_SLAVE );
}
- if( $dbr->numRows( $res ) ) {
+ if( count($rows) ) {
# Current system - load second to make them override.
$now = wfTimestampNow();
$purgeExpired = false;
- foreach( $res as $row ) {
+ foreach( $rows as $row ) {
# Cycle through all the restrictions.
// Don't take care of restrictions types that aren't in $wgRestrictionTypes
$res = $dbr->select( 'page_restrictions', '*',
array ( 'pr_page' => $this->getArticleId() ), __METHOD__ );
- $this->loadRestrictionsFromRow( $res, $oldFashionedRestrictions );
+ $this->loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions );
} else {
$title_protection = $this->getTitleProtection();