From: Ryan Schmidt Date: Tue, 23 Jun 2009 02:03:47 +0000 (+0000) Subject: * Revert r52201, but modify the shortcut code so that it properly detects "public... X-Git-Tag: 1.31.0-rc.0~41240 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=969ba34c9ff50d51f3cd26cb3e9ae63c0902bf6f;p=lhc%2Fweb%2Fwiklou.git * Revert r52201, but modify the shortcut code so that it properly detects "public" wikis --- diff --git a/includes/Title.php b/includes/Title.php index dd299c842b..d7c65bb597 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1483,13 +1483,37 @@ class Title { */ public function userCanRead() { global $wgUser, $wgGroupPermissions; - + + static $useShortcut = null; + + # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below + if( is_null( $useShortcut ) ) { + global $wgRevokePermissions; + $useShortcut = true; + if( empty( $wgGroupPermissions['*']['read'] ) ) { + # Not a public wiki, so no shortcut + $useShortcut = false; + } elseif( !empty( $wgRevokePermissions ) ) { + foreach( array_keys( $wgRevokePermissions ) as $group ) { + if( !empty( $wgRevokePermissions[$group]['read'] ) ) { + # We might be removing the read right from the user, so no shortcut + $useShortcut = false; + break; + } + } + } + } + $result = null; wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) ); if ( $result !== null ) { return $result; } + # Shortcut for public wikis, allows skipping quite a bit of code + if ( $useShortcut ) + return true; + if( $wgUser->isAllowed( 'read' ) ) { return true; } else {