Revert previous commit, breaks cache.
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
index dffa2e4..5f27944 100644 (file)
@@ -80,8 +80,14 @@ class MovePageForm {
                $this->watch = $wgRequest->getCheck( 'wpWatch' );
        }
 
+       /**
+        * Show the form
+        * @param mixed $err Error message. May either be a string message name or 
+        *    array message name and parameters, like the second argument to 
+        *    OutputPage::wrapWikiMsg(). 
+        */
        function showForm( $err ) {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgFixDoubleRedirects;
 
                $skin = $wgUser->getSkin();
 
@@ -97,21 +103,17 @@ class MovePageForm {
                        # when the form is first opened.
                        $newTitle = $this->oldTitle;
                }
-               // WTF is this doing, passing title *object* to newFromUrl()??
-               /*else {
+               else {
                        if( empty($err) ) {
-                               $nt = Title::newFromURL( $this->newTitle );
-                               if( $nt ) {
-                                       # If a title was supplied, probably from the move log revert
-                                       # link, check for validity. We can then show some diagnostic
-                                       # information and save a click.
-                                       $newerr = $this->oldTitle->isValidMoveOperation( $nt );
-                                       if( is_string( $newerr ) ) {
-                                               $err = $newerr;
-                                       }
+                               # If a title was supplied, probably from the move log revert
+                               # link, check for validity. We can then show some diagnostic
+                               # information and save a click.
+                               $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
+                               if( $newerr ) {
+                                       $err = $newerr[0];
                                }
                        }
-               }*/
+               }
 
                if ( !empty($err) && $err[0] == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
                        $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
@@ -136,12 +138,16 @@ class MovePageForm {
                $considerTalk = ( !$this->oldTitle->isTalkPage() && $oldTalk->exists() );
 
                $dbr = wfGetDB( DB_SLAVE );
-               $hasRedirects = $dbr->selectField( 'redirect', '1', 
-                       array( 
-                               'rd_namespace' => $this->oldTitle->getNamespace(),
-                               'rd_title' => $this->oldTitle->getDBkey(),
-                       ) , __METHOD__ );
-               
+               if ( $wgFixDoubleRedirects ) {
+                       $hasRedirects = $dbr->selectField( 'redirect', '1', 
+                               array( 
+                                       'rd_namespace' => $this->oldTitle->getNamespace(),
+                                       'rd_title' => $this->oldTitle->getDBkey(),
+                               ) , __METHOD__ );
+               } else {
+                       $hasRedirects = false;
+               }
+
                if ( $considerTalk ) {
                        $wgOut->addWikiMsg( 'movepagetalktext' );
                }
@@ -277,6 +283,7 @@ class MovePageForm {
 
        function doSubmit() {
                global $wgOut, $wgUser, $wgRequest, $wgMaximumMovedPages, $wgLang;
+               global $wgFixDoubleRedirects;
 
                if ( $wgUser->pingLimiter( 'move' ) ) {
                        $wgOut->rateLimited();
@@ -316,11 +323,12 @@ class MovePageForm {
 
                $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
                if ( $error !== true ) {
-                       call_user_func_array( array($this, 'showForm'), $error );
+                       # FIXME: show all the errors in a list, not just the first one
+                       $this->showForm( reset( $error ) );
                        return;
                }
 
-               if ( $this->fixRedirects ) {
+               if ( $wgFixDoubleRedirects && $this->fixRedirects ) {
                        DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
                }