From: Aryeh Gregor Date: Mon, 24 Mar 2008 13:40:45 +0000 (+0000) Subject: Moving some optimization code into User::isAllowed instead of higher up in Title... X-Git-Tag: 1.31.0-rc.0~48853 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=73c025c25c24ff7a0e72feeb49dcbbe4cfca28e8;p=lhc%2Fweb%2Fwiklou.git Moving some optimization code into User::isAllowed instead of higher up in Title.php. Also, adding a comment so that people maybe aren't going to randomly remove it without thinking what it does. ;) --- diff --git a/includes/Namespace.php b/includes/Namespace.php index b31b2404a1..71e3654520 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -165,4 +165,4 @@ class MWNamespace { return $index >= NS_MAIN; } -} \ No newline at end of file +} diff --git a/includes/Title.php b/includes/Title.php index 0c91eab141..d91036ab99 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1387,7 +1387,7 @@ class Title { * @todo fold these checks into userCan() */ public function userCanRead() { - global $wgUser, $wgGroupPermissions; + global $wgUser; $result = null; wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) ); @@ -1395,10 +1395,6 @@ class Title { return $result; } - # Shortcut for public wikis, allows skipping quite a bit of code - if ($wgGroupPermissions['*']['read']) - return true; - if( $wgUser->isAllowed( 'read' ) ) { return true; } else { diff --git a/includes/User.php b/includes/User.php index a8bfbe65d3..f4edaf2675 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1770,9 +1770,16 @@ class User { * @return boolean True: action is allowed, False: action should not be allowed */ function isAllowed($action='') { - if ( $action === '' ) + global $wgGroupPermissions; + if( $action === '' ) { // In the spirit of DWIM return true; + } + if( !empty( $wgGroupPermissions['*'][$action] ) ) { + # Permissions are additive, so there's no need to unstub the User + # object in this case. + return true; + } return in_array( $action, $this->getRights() ); }