r19002 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19001‎ | r19002 | r19003 >
Date:04:11, 9 January 2007
Author:werdna
Status:old
Tags:
Comment:
Progress commit on apparently functional cascade protection. Still need to write database updates, profile, optimise before merging
Modified paths:
  • /branches/werdna/restrictions-separation/includes/Title.php (modified) (history)

Diff [purge]

Index: branches/werdna/restrictions-separation/includes/Title.php
@@ -1117,6 +1117,17 @@
11181118 return false;
11191119 }
11201120
 1121+ if ($this->isCascadeProtectedPage()) {
 1122+ # We /could/ use the protection level on the source page, but it's fairly ugly
 1123+ # as we have to establish a precedence hierarchy for pages included by multiple
 1124+ # cascade-protected pages. So just restrict it to people with 'protect' permission,
 1125+ # as they could remove the protection anyway.
 1126+ if ( !$wgUser->isAllowed('protect') ) {
 1127+ wfProfileOut( $fname );
 1128+ return false;
 1129+ }
 1130+ }
 1131+
11211132 foreach( $this->getRestrictions($action) as $right ) {
11221133 // Backwards compatibility, rewrite sysop -> protect
11231134 if ( $right == 'sysop' ) {
@@ -1317,16 +1328,22 @@
13181329 * @access public
13191330 */
13201331 function isCascadeProtectedPage() {
 1332+ wfProfileIn(__METHOD__);
 1333+
13211334 $dbr = wfGetDb( DB_SLAVE );
13221335
1323 - $cols = array( 'tl_namespace', 'tl_title', 'pr_level', 'pr_type' );
 1336+ $cols = array( 'tl_namespace', 'tl_title'/*, 'pr_level', 'pr_type'*/ );
13241337 $join_clauses = array ('inner join page_restrictions on templatelinks.tl_from=pr_page');
1325 - $where_clauses array( 'tl_namespace' => $this->getNamespace(), 'tl_title' => $this->getText() );
 1338+ $where_clauses = array( 'tl_namespace' => $this->getNamespace(), 'tl_title' => $this->getText() );
13261339
13271340 $res = $dbr->select( 'templatelinks', $cols, $where_clauses, __METHOD, $join_clauses );
13281341
1329 - if ($dbr->numRows) {
 1342+ if ($dbr->numRows($res)) {
 1343+ wfProfileOut(__METHOD__);
13301344 return true;
 1345+ } else {
 1346+ wfProfileOut(__METHOD__);
 1347+ return false;
13311348 }
13321349 }
13331350