From 969ba34c9ff50d51f3cd26cb3e9ae63c0902bf6f Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Tue, 23 Jun 2009 02:03:47 +0000 Subject: [PATCH] * Revert r52201, but modify the shortcut code so that it properly detects "public" wikis --- includes/Title.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 { -- 2.20.1