From e76bc52f1dbd179a3f91ca423c75e6e1a481707f Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 5 Feb 2009 23:29:19 +0000 Subject: [PATCH] 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). --- includes/Title.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) 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__ ); -- 2.20.1