r46931 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46930‎ | r46931 | r46932 >
Date:17:58, 6 February 2009
Author:werdna
Status:deferred
Tags:
Comment:
Revert "Revert r46880, r46902. After issues with editing rights for pages in r46880, there are issues with moving pages in r46902. Repored by Hojjat, confirmed by me.", with the 'issues' fixed -- the problem was that the 'move-target' action wasn't being handled
properly
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1166,6 +1166,59 @@
11671167
11681168 $errors = array();
11691169
 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( $action == 'move-target' ) {
 1195+ if( !$user->isAllowed( 'move' ) ) {
 1196+ // User can't move anything
 1197+ $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1198+ } elseif( !$user->isAllowed( 'move-rootuserpages' )
 1199+ && $this->getNamespace() == NS_USER && !$this->isSubpage() )
 1200+ {
 1201+ // Show user page-specific message only if the user can move other pages
 1202+ $errors[] = array( 'cant-move-to-user-page' );
 1203+ }
 1204+ } elseif( !$user->isAllowed( $action ) ) {
 1205+ $return = null;
 1206+ $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
 1207+ User::getGroupsWithPermission( $action ) );
 1208+ if( $groups ) {
 1209+ $return = array( 'badaccess-groups',
 1210+ array( implode( ', ', $groups ), count( $groups ) ) );
 1211+ } else {
 1212+ $return = array( "badaccess-group0" );
 1213+ }
 1214+ $errors[] = $return;
 1215+ }
 1216+
 1217+ # Short-circuit point
 1218+ if( $short && count($errors) > 0 ) {
 1219+ wfProfileOut( __METHOD__ );
 1220+ return $errors;
 1221+ }
 1222+
11701223 // Use getUserPermissionsErrors instead
11711224 if( !wfRunHooks( 'userCan', array( &$this, &$user, $action, &$result ) ) ) {
11721225 wfProfileOut( __METHOD__ );
@@ -1300,26 +1353,7 @@
13011354 $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason );
13021355 }
13031356 }
1304 -
1305 - if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
1306 - ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) )
1307 - {
1308 - $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
1309 - }
13101357 } elseif( $action == 'move' ) {
1311 - if( !$user->isAllowed( 'move' ) ) {
1312 - // User can't move anything
1313 - $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
1314 - } elseif( !$user->isAllowed( 'move-rootuserpages' )
1315 - && $this->getNamespace() == NS_USER && !$this->isSubpage() )
1316 - {
1317 - // Show user page-specific message only if the user can move other pages
1318 - $errors[] = array( 'cant-move-user-page' );
1319 - }
1320 - // Check if user is allowed to move files if it's a file
1321 - if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) {
1322 - $errors[] = array( 'movenotallowedfile' );
1323 - }
13241358 // Check for immobile pages
13251359 if( !MWNamespace::isMovable( $this->getNamespace() ) ) {
13261360 // Specific message for this case
@@ -1329,31 +1363,11 @@
13301364 $errors[] = array( 'immobile-page' );
13311365 }
13321366 } elseif( $action == 'move-target' ) {
1333 - if( !$user->isAllowed( 'move' ) ) {
1334 - // User can't move anything
1335 - $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
1336 - } elseif( !$user->isAllowed( 'move-rootuserpages' )
1337 - && $this->getNamespace() == NS_USER && !$this->isSubpage() )
1338 - {
1339 - // Show user page-specific message only if the user can move other pages
1340 - $errors[] = array( 'cant-move-to-user-page' );
1341 - }
13421367 if( !MWNamespace::isMovable( $this->getNamespace() ) ) {
13431368 $errors[] = array( 'immobile-target-namespace', $this->getNsText() );
13441369 } elseif( !$this->isMovable() ) {
13451370 $errors[] = array( 'immobile-target-page' );
13461371 }
1347 - } elseif( !$user->isAllowed( $action ) ) {
1348 - $return = null;
1349 - $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
1350 - User::getGroupsWithPermission( $action ) );
1351 - if( $groups ) {
1352 - $return = array( 'badaccess-groups',
1353 - array( implode( ', ', $groups ), count( $groups ) ) );
1354 - } else {
1355 - $return = array( "badaccess-group0" );
1356 - }
1357 - $errors[] = $return;
13581372 }
13591373
13601374 wfProfileOut( __METHOD__ );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46880Move permissions check in getUserPermissionsErrorsInternal up to the top. The...werdna23:29, 5 February 2009
r46902Fix for r46880 -- didn't take into account that the action does not always co...werdna07:24, 6 February 2009

Status & tagging log