r41961 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41960‎ | r41961 | r41962 >
Date:08:26, 11 October 2008
Author:tstarling
Status:old (Comments)
Tags:
Comment:
* Reintroduce user page move permission as per r41465, generally useful regardless of whether the Renameuser extension is in use. Do the check in Title::getUserPermissionsErrorsInternal(), so that the move page tab won't be displayed on user pages for users who can't move them.
* Use error message text suitable for humans. Be specific about whether the source or the destination is the problem, say what the namespace is for those people who don't get namespaces, don't introduce unnecessary jargon words like "root" for a page that isn't a subpage.
* Fixed incorrect display of movenotallowed for immobile namespaces, use the new specific error messages.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1221,8 +1221,43 @@
12221222 ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) {
12231223 $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
12241224 }
1225 - } elseif( $action == 'move' && !( $this->isMovable() && $user->isAllowed( 'move' ) ) ) {
1226 - $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1225+
 1226+ } elseif ( $action == 'move' ) {
 1227+ if ( !$user->isAllowed( 'move' ) ) {
 1228+ // User can't move anything
 1229+ $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1230+ } elseif ( !$user->isAllowed( 'move-rootuserpages' )
 1231+ && $this->getNamespace() == NS_USER && !$this->isSubpage() )
 1232+ {
 1233+ // Show user page-specific message only if the user can move other pages
 1234+ $errors[] = array( 'cant-move-user-page' );
 1235+ }
 1236+
 1237+ // Check for immobile pages
 1238+ if ( !MWNamespace::isMovable( $this->getNamespace() ) ) {
 1239+ // Specific message for this case
 1240+ $errors[] = array( 'immobile-source-namespace', $this->getNsText() );
 1241+ } elseif ( !$this->isMovable() ) {
 1242+ // Less specific message for rarer cases
 1243+ $errors[] = array( 'immobile-page' );
 1244+ }
 1245+
 1246+ } elseif ( $action == 'move-target' ) {
 1247+ if ( !$user->isAllowed( 'move' ) ) {
 1248+ // User can't move anything
 1249+ $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
 1250+ } elseif ( !$user->isAllowed( 'move-rootuserpages' )
 1251+ && $this->getNamespace() == NS_USER && !$this->isSubpage() )
 1252+ {
 1253+ // Show user page-specific message only if the user can move other pages
 1254+ $errors[] = array( 'cant-move-to-user-page' );
 1255+ }
 1256+ if ( !MWNamespace::isMovable( $this->getNamespace() ) ) {
 1257+ $errors[] = array( 'immobile-target-namespace', $this->getNsText() );
 1258+ } elseif ( !$this->isMovable() ) {
 1259+ $errors[] = array( 'immobile-target-page' );
 1260+ }
 1261+
12271262 } elseif ( !$user->isAllowed( $action ) ) {
12281263 $return = null;
12291264 $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
@@ -2380,6 +2415,8 @@
23812416 * @return \type{\mixed} True on success, getUserPermissionsErrors()-like array on failure
23822417 */
23832418 public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
 2419+ global $wgUser;
 2420+
23842421 $errors = array();
23852422 if( !$nt ) {
23862423 // Normally we'd add this to $errors, but we'll get
@@ -2389,9 +2426,12 @@
23902427 if( $this->equals( $nt ) ) {
23912428 $errors[] = array('selfmove');
23922429 }
2393 - if( !$this->isMovable() || !$nt->isMovable() ) {
2394 - $errors[] = array('immobile_namespace');
 2430+ if( !$this->isMovable() ) {
 2431+ $errors[] = array( 'immobile-source-namespace', $this->getNsText() );
23952432 }
 2433+ if ( !$nt->isMovable() ) {
 2434+ $errors[] = array('immobile-target-namespace', $nt->getNsText() );
 2435+ }
23962436
23972437 $oldid = $this->getArticleID();
23982438 $newid = $nt->getArticleID();
@@ -2422,11 +2462,10 @@
24232463 }
24242464
24252465 if ( $auth ) {
2426 - global $wgUser;
24272466 $errors = wfArrayMerge($errors,
24282467 $this->getUserPermissionsErrors('move', $wgUser),
24292468 $this->getUserPermissionsErrors('edit', $wgUser),
2430 - $nt->getUserPermissionsErrors('move', $wgUser),
 2469+ $nt->getUserPermissionsErrors('move-target', $wgUser),
24312470 $nt->getUserPermissionsErrors('edit', $wgUser));
24322471 }
24332472
@@ -2436,7 +2475,6 @@
24372476 $errors[] = array('spamprotectiontext');
24382477 }
24392478
2440 - global $wgUser;
24412479 $err = null;
24422480 if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err, $reason ) ) ) {
24432481 $errors[] = array('hookaborted', $err);
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1128,6 +1128,7 @@
11291129 // Implicit group for all logged-in accounts
11301130 $wgGroupPermissions['user' ]['move'] = true;
11311131 $wgGroupPermissions['user' ]['move-subpages'] = true;
 1132+$wgGroupPermissions['user' ]['move-rootuserpages'] = true; // can move root userpages
11321133 $wgGroupPermissions['user' ]['read'] = true;
11331134 $wgGroupPermissions['user' ]['edit'] = true;
11341135 $wgGroupPermissions['user' ]['createpage'] = true;
@@ -1166,6 +1167,7 @@
11671168 $wgGroupPermissions['sysop']['importupload'] = true;
11681169 $wgGroupPermissions['sysop']['move'] = true;
11691170 $wgGroupPermissions['sysop']['move-subpages'] = true;
 1171+$wgGroupPermissions['sysop']['move-rootuserpages'] = true;
11701172 $wgGroupPermissions['sysop']['patrol'] = true;
11711173 $wgGroupPermissions['sysop']['autopatrol'] = true;
11721174 $wgGroupPermissions['sysop']['protect'] = true;
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2660,7 +2660,11 @@
26612661
26622662 In those cases, you will have to move or merge the page manually if desired.",
26632663 'movearticle' => 'Move page:',
 2664+'movenologin' => 'Not logged in',
 2665+'movenologintext' => 'You must be a registered user and [[Special:Userlogin|logged in]] to move a page.',
26642666 'movenotallowed' => 'You do not have permission to move pages.',
 2667+'cant-move-user-page' => 'You do not have permission to move user pages (apart from subpages).',
 2668+'cant-move-to-user-page' => 'You do not have permission to move a page to a user page (except to a user subpage).',
26652669 'newtitle' => 'To new title:',
26662670 'move-watch' => 'Watch this page',
26672671 'movepagebtn' => 'Move page',
@@ -2693,8 +2697,10 @@
26942698 'delete_and_move_reason' => 'Deleted to make way for move',
26952699 'selfmove' => 'Source and destination titles are the same;
26962700 cannot move a page over itself.',
2697 -'immobile_namespace' => 'Source or destination title is of a special type;
2698 -cannot move pages from and into that namespace.',
 2701+'immobile-source-namespace' => 'Cannot move pages in namespace "$1"',
 2702+'immobile-target-namespace' => 'Cannot move pages into namespace "$1"',
 2703+'immobile-source-page' => 'This page is not movable.',
 2704+'immobile-target-page' => 'Cannot move to that destination title.',
26992705 'imagenocrossnamespace' => 'Cannot move file to non-file namespace',
27002706 'imagetypemismatch' => 'The new file extension does not match its type',
27012707 'imageinvalidfilename' => 'The target file name is invalid',

Follow-up revisions

RevisionCommit summaryAuthorDate
r41963Continuation of r41961: remove this move page hook since I just readded the f...tstarling08:33, 11 October 2008
r95756Fix a message key typo in r41961 (!!), which didn't matter before because the...catrope11:39, 30 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41465Adding a new right, move-rootuserpages....nicdumz07:51, 1 October 2008

Comments

#Comment by Voice of All (talk | contribs)   18:25, 11 October 2008

Where does move-target come from?

#Comment by Brion VIBBER (talk | contribs)   02:47, 13 October 2008

Title::isValidMoveOperation() uses separate actions for the move source and move target when building up the permission/error checks:

			$errors = wfArrayMerge($errors, 
					$this->getUserPermissionsErrors('move', $wgUser),
					$this->getUserPermissionsErrors('edit', $wgUser),
					$nt->getUserPermissionsErrors('move-target', $wgUser),
					$nt->getUserPermissionsErrors('edit', $wgUser));

Status & tagging log