[Special:MovePage] Split new title input, fix bug 29454 (byteLimit), namespaceSelector
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 28 Jan 2012 16:26:12 +0000 (16:26 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 28 Jan 2012 16:26:12 +0000 (16:26 +0000)
* Two reasons:
-- Limit bug: Limit can't be enforced if the two are together
because only page_title is limited, the namespace prefix
is not part of the title. Plus even then, there is still
ambiguity with the various ways to denote namespaces (aliases)
and whitespace freedom between namespace, colon and title.
-- Extra feature: Now that the two are separate it' s easier
for users to move across namespaces as one doesn't have to type,
can't make spelling mistakes. Also, in the future we could exclude
certain target namespaces that are not possible or not allowed (now one can
perfectly submit a request to move from NS_CATEGORY or NS_FILE, only to
get a warning on submission). By showing them disabled in the drop down
this becomes clearer).

* Keeps backwards compatibility for gadgets and permalinks generated
by templates on wikis so that they can still pre-set the "new title"
from a url the old way. The new way can also be pre-set from the url,
and allows them to be set separately (wpNewTitleNs=10&wpNewTitleMain=Infobox)
* Gadgets and templates linking to Special:MovePage with a preset target
-- Old way (still works): wpNewTitle=Template:Infobox
-- New way: wpNewTitleNs=10 (and/or) wpNewTitleMain=Infobox

* Fixes bug 29454; Depends on r109990;
-- (bug 29454) Enforce byteLimit for page title input on Special:MovePage

RELEASE-NOTES-1.19
includes/specials/SpecialMovepage.php
resources/mediawiki.special/mediawiki.special.movePage.js

index 72d22ab..92ff7df 100644 (file)
@@ -124,6 +124,7 @@ production.
 * (bug 30513) Redirect tag is now resolved in XML dump file.
 * sha1 xml tag added to XML dump file. 
 * (bug 33646) Badtitle error page now emits a 400 HTTP status.
+* Special:MovePage now has a dropdown menu for namespaces.
 
 === Bug fixes in 1.19 ===
 * $wgUploadNavigationUrl should be used for file redlinks if.
@@ -240,6 +241,7 @@ production.
 * (bug 33902) Decoding %2B with mw.Uri.decode results in ' ' instead of +
 * (bug 33762) QueryPage-based special pages no longer misses *-summary message.
 * Other sizes links are no longer generated for wikis without a 404 thumbnail handler.
+* (bug 29454) Enforce byteLimit for page title input on Special:MovePage
 
 === API changes in 1.19 ===
 * Made action=edit less likely to return "unknownerror", by returning the actual error
index 5920440..ad45ed8 100644 (file)
@@ -51,11 +51,18 @@ class MovePageForm extends UnlistedSpecialPage {
                $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
 
                // Yes, the use of getVal() and getText() is wanted, see bug 20365
-               $oldTitleText = $request->getVal( 'wpOldTitle', $target );
-               $newTitleText = $request->getText( 'wpNewTitle' );
 
+               $oldTitleText = $request->getVal( 'wpOldTitle', $target );
                $this->oldTitle = Title::newFromText( $oldTitleText );
-               $this->newTitle = Title::newFromText( $newTitleText );
+
+               $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
+               $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
+               // Backwards compatibility for forms submitting here from other sources
+               // which is more common than it should be..
+               $newTitleText_bc = $request->getText( 'wpNewTitle' );
+               $this->newTitle = strlen( $newTitleText_bc ) > 0
+                       ? Title::newFromText( $newTitleText_bc )
+                       : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
 
                if( is_null( $this->oldTitle ) ) {
                        throw new ErrorPageError( 'notargettitle', 'notargettext' );
@@ -113,7 +120,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
                $newTitle = $this->newTitle;
 
-               if( !$newTitle ) {
+               if ( !$newTitle ) {
                        # Show the current title as a default
                        # when the form is first opened.
                        $newTitle = $this->oldTitle;
@@ -235,6 +242,9 @@ class MovePageForm extends UnlistedSpecialPage {
                        $out->addHTML( "</div>\n" );
                }
 
+               // Byte limit (not string length limit) for wpReason and wpNewTitleMain
+               // is enforced in the mediawiki.special.movePage module
+
                $out->addHTML(
                         Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
                         Xml::openElement( 'fieldset' ) .
@@ -250,10 +260,18 @@ class MovePageForm extends UnlistedSpecialPage {
                        </tr>
                        <tr>
                                <td class='mw-label'>" .
-                                       Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
+                                       Xml::label( wfMsg( 'newtitle' ), 'wpNewTitleMain' ) .
                                "</td>
                                <td class='mw-input'>" .
-                                       Xml::input( 'wpNewTitle', 60, $wgContLang->recodeForEdit( $newTitle->getPrefixedText() ), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
+                                       Html::namespaceSelector(
+                                               array( 'selected' => $newTitle->getNamespace() ),
+                                               array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
+                                       ) .
+                                       Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getBaseText() ), array(
+                                               'type' => 'text',
+                                               'id' => 'wpNewTitleMain',
+                                               'maxlength' => 255,
+                                       ) ) .
                                        Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
                                "</td>
                        </tr>
@@ -263,7 +281,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                "</td>
                                <td class='mw-input'>" .
                                        Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
-                                       'maxlength' => 200 ), $this->reason ) . // maxlength byte limit is enforce in mediawiki.special.movePage.js
+                                       'maxlength' => 200 ), $this->reason ) .
                                "</td>
                        </tr>"
                );
index 2f94cc0..68c2ed0 100644 (file)
@@ -1,5 +1,5 @@
 /* JavaScript for Special:MovePage */
 
 jQuery( function( $ ) {
-       $( '#wpReason' ).byteLimit();
+       $( '#wpReason, #wpNewTitleMain' ).byteLimit();
 });