Moving some optimization code into User::isAllowed instead of higher up in Title...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 24 Mar 2008 13:40:45 +0000 (13:40 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 24 Mar 2008 13:40:45 +0000 (13:40 +0000)
includes/Namespace.php
includes/Title.php
includes/User.php

index b31b240..71e3654 100644 (file)
@@ -165,4 +165,4 @@ class MWNamespace {
                return $index >= NS_MAIN;
        }
         
-}
\ No newline at end of file
+}
index 0c91eab..d91036a 100644 (file)
@@ -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 {
index a8bfbe6..f4edaf2 100644 (file)
@@ -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() );
        }