Index: branches/werdna/restrictions-separation/includes/Title.php |
— | — | @@ -1117,6 +1117,17 @@ |
1118 | 1118 | return false; |
1119 | 1119 | } |
1120 | 1120 | |
| 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 | + |
1121 | 1132 | foreach( $this->getRestrictions($action) as $right ) { |
1122 | 1133 | // Backwards compatibility, rewrite sysop -> protect |
1123 | 1134 | if ( $right == 'sysop' ) { |
— | — | @@ -1317,16 +1328,22 @@ |
1318 | 1329 | * @access public |
1319 | 1330 | */ |
1320 | 1331 | function isCascadeProtectedPage() { |
| 1332 | + wfProfileIn(__METHOD__); |
| 1333 | + |
1321 | 1334 | $dbr = wfGetDb( DB_SLAVE ); |
1322 | 1335 | |
1323 | | - $cols = array( 'tl_namespace', 'tl_title', 'pr_level', 'pr_type' ); |
| 1336 | + $cols = array( 'tl_namespace', 'tl_title'/*, 'pr_level', 'pr_type'*/ ); |
1324 | 1337 | $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() ); |
1326 | 1339 | |
1327 | 1340 | $res = $dbr->select( 'templatelinks', $cols, $where_clauses, __METHOD, $join_clauses ); |
1328 | 1341 | |
1329 | | - if ($dbr->numRows) { |
| 1342 | + if ($dbr->numRows($res)) { |
| 1343 | + wfProfileOut(__METHOD__); |
1330 | 1344 | return true; |
| 1345 | + } else { |
| 1346 | + wfProfileOut(__METHOD__); |
| 1347 | + return false; |
1331 | 1348 | } |
1332 | 1349 | } |
1333 | 1350 | |