Fixes for r64708:
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
index 4dbadcf..02197b1 100644 (file)
@@ -63,7 +63,7 @@ class MovePageForm {
        private $watch = false;
 
        function __construct( $oldTitle, $newTitle ) {
-               global $wgRequest;
+               global $wgRequest, $wgUser;
                $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
                $this->oldTitle = $oldTitle;
                $this->newTitle = $newTitle;
@@ -80,7 +80,7 @@ class MovePageForm {
                $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false );
                $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
                $this->moveOverShared = $wgRequest->getBool( 'wpMoveOverSharedFile', false );
-               $this->watch = $wgRequest->getCheck( 'wpWatch' );
+               $this->watch = $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn();
        }
 
        /**
@@ -131,6 +131,9 @@ class MovePageForm {
                                </tr>";
                        $err = '';
                } else {
+                       if ($this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
+                               $wgOut->wrapWikiMsg( "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>", 'moveuserpage-warning' );
+                       }
                        $wgOut->addWikiMsg( 'movepagetext' );
                        $movepagebtn = wfMsg( 'movepagebtn' );
                        $submitVar = 'wpMove';
@@ -218,7 +221,8 @@ class MovePageForm {
                                        Xml::label( wfMsg( 'movereason' ), 'wpReason' ) .
                                "</td>
                                <td class='mw-input'>" .
-                                       Xml::tags( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2 ), htmlspecialchars( $this->reason ) ) .
+                                       Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
+                                       'maxlength' => 200 ), $this->reason ) .
                                "</td>
                        </tr>"
                );
@@ -290,15 +294,20 @@ class MovePageForm {
                        );
                }
 
-               $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) 
-                       || $this->oldTitle->userIsWatching();
-               $wgOut->addHTML( "
+               $watchChecked = $wgUser->isLoggedIn() && ($this->watch || $wgUser->getBoolOption( 'watchmoves' ) 
+                       || $this->oldTitle->userIsWatching());
+               # Don't allow watching if user is not logged in
+               if( $wgUser->isLoggedIn() ) {
+                       $wgOut->addHTML( "
                        <tr>
                                <td></td>
                                <td class='mw-input'>" .
                                        Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
                                "</td>
-                       </tr>
+                       </tr>");
+               }
+
+               $wgOut->addHTML( "      
                                {$confirm}
                        <tr>
                                <td>&nbsp;</td>
@@ -476,7 +485,7 @@ class MovePageForm {
 
                        $newPageName = preg_replace(
                                '#^'.preg_quote( $ot->getDBkey(), '#' ).'#',
-                               str_replace( '\\', '\\\\', $nt->getDBkey() ), # bug 21234
+                               StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
                                $oldSubpage->getDBkey()
                        );
                        if( $oldSubpage->isTalkPage() ) {
@@ -531,17 +540,24 @@ class MovePageForm {
                }
 
                # Deal with watches (we don't watch subpages)
-               if( $this->watch ) {
+               if( $this->watch && $wgUser->isLoggedIn() ) {
                        $wgUser->addWatch( $ot );
                        $wgUser->addWatch( $nt );
                } else {
                        $wgUser->removeWatch( $ot );
                        $wgUser->removeWatch( $nt );
                }
+               
+               # Re-clear the file redirect cache, which may have been polluted by 
+               # parsing in messages above. See CR r56745.
+               # FIXME: needs a more robust solution inside FileRepo.
+               if( $ot->getNamespace() == NS_FILE ) {
+                       RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $ot );
+               }
        }
 
        function showLogFragment( $title, &$out ) {
-               $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'move' ) ) );
+               $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'move' ) ) );
                LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() );
        }