r46902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46901‎ | r46902 | r46903 >
Date:07:24, 6 February 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Fix for r46880 -- didn't take into account that the action does not always correspond directly to the required permission.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1166,7 +1166,31 @@
11671167
11681168 $errors = array();
11691169
1170 - if( !$user->isAllowed( $action ) ) {
 1170+ // First stop is permissions checks, which fail most often, and which are easiest to test.
 1171+ if ( $action == 'move' ) {
 1172+ if( !$user->isAllowed( 'move-rootuserpages' )
 1173+ && $this->getNamespace() == NS_USER && !$this->isSubpage() )
 1174+ {
 1175+ // Show user page-specific message only if the user can move other pages
 1176+ $errors[] = array( 'cant-move-user-page' );
 1177+ }
 1178+
 1179+ // Check if user is allowed to move files if it's a file
 1180+ if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) {
 1181+ $errors[] = array( 'movenotallowedfile' );
 1182+ }
 1183+
 1184+ if( !$user->isAllowed( 'move' ) ) {
 1185+ // User can't move anything
 1186+ $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1187+ }
 1188+ } elseif ( $action == 'create' ) {
 1189+ if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
 1190+ ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) )
 1191+ {
 1192+ $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
 1193+ }
 1194+ } elseif( !$user->isAllowed( $action ) ) {
11711195 $return = null;
11721196 $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
11731197 User::getGroupsWithPermission( $action ) );
@@ -1315,26 +1339,7 @@
13161340 $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason );
13171341 }
13181342 }
1319 -
1320 - if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
1321 - ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) )
1322 - {
1323 - $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
1324 - }
13251343 } elseif( $action == 'move' ) {
1326 - if( !$user->isAllowed( 'move' ) ) {
1327 - // User can't move anything
1328 - $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
1329 - } elseif( !$user->isAllowed( 'move-rootuserpages' )
1330 - && $this->getNamespace() == NS_USER && !$this->isSubpage() )
1331 - {
1332 - // Show user page-specific message only if the user can move other pages
1333 - $errors[] = array( 'cant-move-user-page' );
1334 - }
1335 - // Check if user is allowed to move files if it's a file
1336 - if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) {
1337 - $errors[] = array( 'movenotallowedfile' );
1338 - }
13391344 // Check for immobile pages
13401345 if( !MWNamespace::isMovable( $this->getNamespace() ) ) {
13411346 // Specific message for this case

Follow-up revisions

RevisionCommit summaryAuthorDate
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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46880Move permissions check in getUserPermissionsErrorsInternal up to the top. The...werdna23:29, 5 February 2009

Comments

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

Reverted in r46912 (together with r46880), because of issues with page moves.

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

Re-added in r46931.

Status & tagging log