Merge "fixed timestamp validation for api"
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
index 3ece917..66fd918 100644 (file)
@@ -254,11 +254,13 @@ class MovePageForm extends UnlistedSpecialPage {
                        }
                }
 
+               $handler = ContentHandler::getForTitle( $this->oldTitle );
+
                $out->addHTML(
                         Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
                         Xml::openElement( 'fieldset' ) .
                         Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
-                        Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-movepage-table' ) ) .
+                        Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) .
                         "<tr>
                                <td class='mw-label'>" .
                                        $this->msg( 'movearticle' )->escaped() .
@@ -309,7 +311,7 @@ class MovePageForm extends UnlistedSpecialPage {
                        );
                }
 
-               if ( $user->isAllowed( 'suppressredirect' ) ) {
+               if ( $user->isAllowed( 'suppressredirect' ) && $handler->supportsRedirects() ) {
                        $out->addHTML( "
                                <tr>
                                        <td></td>
@@ -447,7 +449,11 @@ class MovePageForm extends UnlistedSpecialPage {
                        }
                }
 
-               if ( $user->isAllowed( 'suppressredirect' ) ) {
+               $handler = ContentHandler::getForTitle( $ot );
+
+               if ( !$handler->supportsRedirects() ) {
+                       $createRedirect = false;
+               } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
                        $createRedirect = $this->leaveRedirect;
                } else {
                        $createRedirect = true;
@@ -464,8 +470,6 @@ class MovePageForm extends UnlistedSpecialPage {
                        DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
                }
 
-               wfRunHooks( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
-
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
 
@@ -479,11 +483,24 @@ class MovePageForm extends UnlistedSpecialPage {
                $oldText = $ot->getPrefixedText();
                $newText = $nt->getPrefixedText();
 
-               $msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
+               if ( $ot->exists() ) {
+                       //NOTE: we assume that if the old title exists, it's because it was re-created as
+                       // a redirect to the new title. This is not safe, but what we did before was
+                       // even worse: we just determined whether a redirect should have been created,
+                       // and reported that it was created if it should have, without any checks.
+                       // Also note that isRedirect() is unreliable because of bug 37209.
+                       $msgName = 'movepage-moved-redirect';
+               } else {
+                       $msgName = 'movepage-moved-noredirect';
+               }
+
+
                $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
                        $newLink )->params( $oldText, $newText )->parseAsBlock() );
                $out->addWikiMsg( $msgName );
 
+               wfRunHooks( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
+
                # Now we move extra pages we've been asked to move: subpages and talk
                # pages.  First, if the old page or the new page is a talk page, we
                # can't move any talk pages: cancel that.