From: Andrew Garrett Date: Thu, 5 Feb 2009 23:29:19 +0000 (+0000) Subject: Move permissions check in getUserPermissionsErrorsInternal up to the top. There's... X-Git-Tag: 1.31.0-rc.0~43019 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=e76bc52f1dbd179a3f91ca423c75e6e1a481707f;p=lhc%2Fweb%2Fwiklou.git Move permissions check in getUserPermissionsErrorsInternal up to the top. There's little use in short-circuiting in this method if we do the operations in order from most expensive (and least likely to short-circuit) to least expensive (and most likely to short-circuit). --- diff --git a/includes/Title.php b/includes/Title.php index 7098510ab6..dff205f486 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1166,6 +1166,25 @@ class Title { $errors = array(); + if( !$user->isAllowed( $action ) ) { + $return = null; + $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), + User::getGroupsWithPermission( $action ) ); + if( $groups ) { + $return = array( 'badaccess-groups', + array( implode( ', ', $groups ), count( $groups ) ) ); + } else { + $return = array( "badaccess-group0" ); + } + $errors[] = $return; + } + + # Short-circuit point + if( $short && count($errors) > 0 ) { + wfProfileOut( __METHOD__ ); + return $errors; + } + // Use getUserPermissionsErrors instead if( !wfRunHooks( 'userCan', array( &$this, &$user, $action, &$result ) ) ) { wfProfileOut( __METHOD__ ); @@ -1339,17 +1358,6 @@ class Title { } elseif( !$this->isMovable() ) { $errors[] = array( 'immobile-target-page' ); } - } elseif( !$user->isAllowed( $action ) ) { - $return = null; - $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), - User::getGroupsWithPermission( $action ) ); - if( $groups ) { - $return = array( 'badaccess-groups', - array( implode( ', ', $groups ), count( $groups ) ) ); - } else { - $return = array( "badaccess-group0" ); - } - $errors[] = $return; } wfProfileOut( __METHOD__ );