r46880 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46879‎ | r46880 | r46881 >
Date:23:29, 5 February 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1166,6 +1166,25 @@
11671167
11681168 $errors = array();
11691169
 1170+ if( !$user->isAllowed( $action ) ) {
 1171+ $return = null;
 1172+ $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
 1173+ User::getGroupsWithPermission( $action ) );
 1174+ if( $groups ) {
 1175+ $return = array( 'badaccess-groups',
 1176+ array( implode( ', ', $groups ), count( $groups ) ) );
 1177+ } else {
 1178+ $return = array( "badaccess-group0" );
 1179+ }
 1180+ $errors[] = $return;
 1181+ }
 1182+
 1183+ # Short-circuit point
 1184+ if( $short && count($errors) > 0 ) {
 1185+ wfProfileOut( __METHOD__ );
 1186+ return $errors;
 1187+ }
 1188+
11701189 // Use getUserPermissionsErrors instead
11711190 if( !wfRunHooks( 'userCan', array( &$this, &$user, $action, &$result ) ) ) {
11721191 wfProfileOut( __METHOD__ );
@@ -1339,17 +1358,6 @@
13401359 } elseif( !$this->isMovable() ) {
13411360 $errors[] = array( 'immobile-target-page' );
13421361 }
1343 - } elseif( !$user->isAllowed( $action ) ) {
1344 - $return = null;
1345 - $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
1346 - User::getGroupsWithPermission( $action ) );
1347 - if( $groups ) {
1348 - $return = array( 'badaccess-groups',
1349 - array( implode( ', ', $groups ), count( $groups ) ) );
1350 - } else {
1351 - $return = array( "badaccess-group0" );
1352 - }
1353 - $errors[] = $return;
13541362 }
13551363
13561364 wfProfileOut( __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r46902Fix for r46880 -- didn't take into account that the action does not always co...werdna07:24, 6 February 2009
r46912Revert r46880, r46902. After issues with editing rights for pages in r46880, ...siebrand12:27, 6 February 2009
r46931Revert "Revert r46880, r46902. After issues with editing rights for pages in ...werdna17:58, 6 February 2009

Comments

#Comment by Werdna (talk | contribs)   07:10, 6 February 2009

Reports from Siebrand that this is denying all edits to protected namespaces on translatewiki. Investigating.

#Comment by Werdna (talk | contribs)   07:26, 6 February 2009

Fixed in r46902 -- it was only denying creations.

#Comment by Siebrand (talk | contribs)   12:29, 6 February 2009

Reverted in r46912, because r46902 had issues with page moves.

#Comment by Werdna (talk | contribs)   18:06, 6 February 2009

Re-added in r46931

Status & tagging log