r52301 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52300‎ | r52301 | r52302 >
Date:02:03, 23 June 2009
Author:skizzerz
Status:resolved
Tags:
Comment:
* Revert r52201, but modify the shortcut code so that it properly detects "public" wikis
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1483,13 +1483,37 @@
14841484 */
14851485 public function userCanRead() {
14861486 global $wgUser, $wgGroupPermissions;
 1487+
 1488+ static $useShortcut = null;
14871489
 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+
14881508 $result = null;
14891509 wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) );
14901510 if ( $result !== null ) {
14911511 return $result;
14921512 }
14931513
 1514+ # Shortcut for public wikis, allows skipping quite a bit of code
 1515+ if ( $useShortcut )
 1516+ return true;
 1517+
14941518 if( $wgUser->isAllowed( 'read' ) ) {
14951519 return true;
14961520 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r52335* follow-up to r52301: make it more clear what this loop is trying to accompl...skizzerz00:37, 24 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r52201* Remove "shortcut" in Title::userCanRead, it prevents $wgRevokePermissions a...skizzerz14:37, 20 June 2009

Status & tagging log