r35990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35989‎ | r35990 | r35991 >
Date:12:39, 7 June 2008
Author:rotem
Status:old
Tags:
Comment:
Standardization of permission errors and other errors in Special:Movepage, to show them earlier, when the user asks to move an article.
Modified paths:
  • /trunk/phase3/includes/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialMovepage.php
@@ -10,25 +10,37 @@
1111 function wfSpecialMovepage( $par = null ) {
1212 global $wgUser, $wgOut, $wgRequest, $action;
1313
14 - # Check rights
15 - if ( !$wgUser->isAllowed( 'move' ) ) {
16 - $wgOut->showPermissionsErrorPage( array( $wgUser->isAnon() ? 'movenologintext' : 'movenotallowed' ) );
 14+ # Check for database lock
 15+ if ( wfReadOnly() ) {
 16+ $wgOut->readOnlyPage();
1717 return;
1818 }
1919
20 - # Don't allow blocked users to move pages
21 - if ( $wgUser->isBlocked() ) {
22 - $wgOut->blockedPage();
 20+ $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' );
 21+ $oldTitle = $wgRequest->getText( 'wpOldTitle', $target );
 22+ $newTitle = $wgRequest->getText( 'wpNewTitle' );
 23+
 24+ # Variables beginning with 'o' for old article 'n' for new article
 25+ $ot = Title::newFromText( $oldTitle );
 26+ $nt = Title::newFromText( $newTitle );
 27+
 28+ if( is_null( $ot ) ) {
 29+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
2330 return;
2431 }
 32+ if( !$ot->exists() ) {
 33+ $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' );
 34+ return;
 35+ }
2536
26 - # Check for database lock
27 - if ( wfReadOnly() ) {
28 - $wgOut->readOnlyPage();
 37+ # Check rights
 38+ $permErrors = $ot->getUserPermissionsErrors( 'move', $wgUser );
 39+ if( !empty( $permErrors ) ) {
 40+ $wgOut->showPermissionsErrorPage( $permErrors );
2941 return;
3042 }
3143
32 - $f = new MovePageForm( $par );
 44+ $f = new MovePageForm( $ot, $nt );
3345
3446 if ( 'submit' == $action && $wgRequest->wasPosted()
3547 && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
@@ -48,11 +60,11 @@
4961
5062 private $watch = false;
5163
52 - function MovePageForm( $par ) {
 64+ function MovePageForm( $oldTitle, $newTitle ) {
5365 global $wgRequest;
5466 $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
55 - $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $target );
56 - $this->newTitle = $wgRequest->getText( 'wpNewTitle' );
 67+ $this->oldTitle = $oldTitle;
 68+ $this->newTitle = $newTitle;
5769 $this->reason = $wgRequest->getText( 'wpReason' );
5870 if ( $wgRequest->wasPosted() ) {
5971 $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', false );
@@ -67,16 +79,7 @@
6880 function showForm( $err, $hookErr = '' ) {
6981 global $wgOut, $wgUser;
7082
71 - $ot = Title::newFromURL( $this->oldTitle );
72 - if( is_null( $ot ) ) {
73 - $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
74 - return;
75 - }
76 - if( !$ot->exists() ) {
77 - $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' );
78 - return;
79 - }
80 -
 83+ $ot = $this->oldTitle;
8184 $sk = $wgUser->getSkin();
8285
8386 $oldTitleLink = $sk->makeLinkObj( $ot );
@@ -244,11 +247,9 @@
245248 return;
246249 }
247250
248 - # Variables beginning with 'o' for old article 'n' for new article
 251+ $ot = $this->oldTitle;
 252+ $nt = $this->newTitle;
249253
250 - $ot = Title::newFromText( $this->oldTitle );
251 - $nt = Title::newFromText( $this->newTitle );
252 -
253254 # Delete to make way if requested
254255 if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove ) {
255256 $article = new Article( $nt );

Follow-up revisions

RevisionCommit summaryAuthorDate
r41911Fix error display on invalid destination title on GET, e.g. with URL /wiki/Sp...tstarling01:02, 10 October 2008

Status & tagging log