Index: trunk/phase3/includes/Title.php |
— | — | @@ -1483,13 +1483,37 @@ |
1484 | 1484 | */ |
1485 | 1485 | public function userCanRead() { |
1486 | 1486 | global $wgUser, $wgGroupPermissions; |
| 1487 | + |
| 1488 | + static $useShortcut = null; |
1487 | 1489 | |
| 1490 | + # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below |
| 1491 | + if( is_null( $useShortcut ) ) { |
| 1492 | + global $wgRevokePermissions; |
| 1493 | + $useShortcut = true; |
| 1494 | + if( empty( $wgGroupPermissions['*']['read'] ) ) { |
| 1495 | + # Not a public wiki, so no shortcut |
| 1496 | + $useShortcut = false; |
| 1497 | + } elseif( !empty( $wgRevokePermissions ) ) { |
| 1498 | + foreach( array_keys( $wgRevokePermissions ) as $group ) { |
| 1499 | + if( !empty( $wgRevokePermissions[$group]['read'] ) ) { |
| 1500 | + # We might be removing the read right from the user, so no shortcut |
| 1501 | + $useShortcut = false; |
| 1502 | + break; |
| 1503 | + } |
| 1504 | + } |
| 1505 | + } |
| 1506 | + } |
| 1507 | + |
1488 | 1508 | $result = null; |
1489 | 1509 | wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) ); |
1490 | 1510 | if ( $result !== null ) { |
1491 | 1511 | return $result; |
1492 | 1512 | } |
1493 | 1513 | |
| 1514 | + # Shortcut for public wikis, allows skipping quite a bit of code |
| 1515 | + if ( $useShortcut ) |
| 1516 | + return true; |
| 1517 | + |
1494 | 1518 | if( $wgUser->isAllowed( 'read' ) ) { |
1495 | 1519 | return true; |
1496 | 1520 | } else { |