r46912 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46911‎ | r46912 | r46913 >
Date:12:27, 6 February 2009
Author:siebrand
Status:reverted (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1166,49 +1166,6 @@
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( !$user->isAllowed( $action ) ) {
1195 - $return = null;
1196 - $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
1197 - User::getGroupsWithPermission( $action ) );
1198 - if( $groups ) {
1199 - $return = array( 'badaccess-groups',
1200 - array( implode( ', ', $groups ), count( $groups ) ) );
1201 - } else {
1202 - $return = array( "badaccess-group0" );
1203 - }
1204 - $errors[] = $return;
1205 - }
1206 -
1207 - # Short-circuit point
1208 - if( $short && count($errors) > 0 ) {
1209 - wfProfileOut( __METHOD__ );
1210 - return $errors;
1211 - }
1212 -
12131170 // Use getUserPermissionsErrors instead
12141171 if( !wfRunHooks( 'userCan', array( &$this, &$user, $action, &$result ) ) ) {
12151172 wfProfileOut( __METHOD__ );
@@ -1339,7 +1296,26 @@
13401297 $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason );
13411298 }
13421299 }
 1300+
 1301+ if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
 1302+ ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) )
 1303+ {
 1304+ $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
 1305+ }
13431306 } elseif( $action == 'move' ) {
 1307+ if( !$user->isAllowed( 'move' ) ) {
 1308+ // User can't move anything
 1309+ $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1310+ } elseif( !$user->isAllowed( 'move-rootuserpages' )
 1311+ && $this->getNamespace() == NS_USER && !$this->isSubpage() )
 1312+ {
 1313+ // Show user page-specific message only if the user can move other pages
 1314+ $errors[] = array( 'cant-move-user-page' );
 1315+ }
 1316+ // Check if user is allowed to move files if it's a file
 1317+ if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) {
 1318+ $errors[] = array( 'movenotallowedfile' );
 1319+ }
13441320 // Check for immobile pages
13451321 if( !MWNamespace::isMovable( $this->getNamespace() ) ) {
13461322 // Specific message for this case
@@ -1363,6 +1339,17 @@
13641340 } elseif( !$this->isMovable() ) {
13651341 $errors[] = array( 'immobile-target-page' );
13661342 }
 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;
13671354 }
13681355
13691356 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

Comments

#Comment by Werdna (talk | contribs)   17:28, 6 February 2009

What "issues" did you encounter?

#Comment by Siebrand (talk | contribs)   17:53, 6 February 2009

Cannot move page.

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

Fixed in r46931

Status & tagging log