r110209 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110208‎ | r110209 | r110210 >
Date:16:26, 28 January 2012
Author:krinkle
Status:resolved (Comments)
Tags:core 
Comment:
[Special:MovePage] Split new title input, fix bug 29454 (byteLimit), namespaceSelector

* 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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.movePage.js (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -124,6 +124,7 @@
125125 * (bug 30513) Redirect tag is now resolved in XML dump file.
126126 * sha1 xml tag added to XML dump file.
127127 * (bug 33646) Badtitle error page now emits a 400 HTTP status.
 128+* Special:MovePage now has a dropdown menu for namespaces.
128129
129130 === Bug fixes in 1.19 ===
130131 * $wgUploadNavigationUrl should be used for file redlinks if.
@@ -240,6 +241,7 @@
241242 * (bug 33902) Decoding %2B with mw.Uri.decode results in ' ' instead of +
242243 * (bug 33762) QueryPage-based special pages no longer misses *-summary message.
243244 * Other sizes links are no longer generated for wikis without a 404 thumbnail handler.
 245+* (bug 29454) Enforce byteLimit for page title input on Special:MovePage
244246
245247 === API changes in 1.19 ===
246248 * Made action=edit less likely to return "unknownerror", by returning the actual error
Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -51,12 +51,19 @@
5252 $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
5353
5454 // Yes, the use of getVal() and getText() is wanted, see bug 20365
 55+
5556 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
56 - $newTitleText = $request->getText( 'wpNewTitle' );
57 -
5857 $this->oldTitle = Title::newFromText( $oldTitleText );
59 - $this->newTitle = Title::newFromText( $newTitleText );
6058
 59+ $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
 60+ $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
 61+ // Backwards compatibility for forms submitting here from other sources
 62+ // which is more common than it should be..
 63+ $newTitleText_bc = $request->getText( 'wpNewTitle' );
 64+ $this->newTitle = strlen( $newTitleText_bc ) > 0
 65+ ? Title::newFromText( $newTitleText_bc )
 66+ : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
 67+
6168 if( is_null( $this->oldTitle ) ) {
6269 throw new ErrorPageError( 'notargettitle', 'notargettext' );
6370 }
@@ -113,7 +120,7 @@
114121
115122 $newTitle = $this->newTitle;
116123
117 - if( !$newTitle ) {
 124+ if ( !$newTitle ) {
118125 # Show the current title as a default
119126 # when the form is first opened.
120127 $newTitle = $this->oldTitle;
@@ -235,6 +242,9 @@
236243 $out->addHTML( "</div>\n" );
237244 }
238245
 246+ // Byte limit (not string length limit) for wpReason and wpNewTitleMain
 247+ // is enforced in the mediawiki.special.movePage module
 248+
239249 $out->addHTML(
240250 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
241251 Xml::openElement( 'fieldset' ) .
@@ -250,10 +260,18 @@
251261 </tr>
252262 <tr>
253263 <td class='mw-label'>" .
254 - Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
 264+ Xml::label( wfMsg( 'newtitle' ), 'wpNewTitleMain' ) .
255265 "</td>
256266 <td class='mw-input'>" .
257 - Xml::input( 'wpNewTitle', 60, $wgContLang->recodeForEdit( $newTitle->getPrefixedText() ), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
 267+ Html::namespaceSelector(
 268+ array( 'selected' => $newTitle->getNamespace() ),
 269+ array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
 270+ ) .
 271+ Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getBaseText() ), array(
 272+ 'type' => 'text',
 273+ 'id' => 'wpNewTitleMain',
 274+ 'maxlength' => 255,
 275+ ) ) .
258276 Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
259277 "</td>
260278 </tr>
@@ -263,7 +281,7 @@
264282 "</td>
265283 <td class='mw-input'>" .
266284 Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
267 - 'maxlength' => 200 ), $this->reason ) . // maxlength byte limit is enforce in mediawiki.special.movePage.js
 285+ 'maxlength' => 200 ), $this->reason ) .
268286 "</td>
269287 </tr>"
270288 );
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.movePage.js
@@ -1,5 +1,5 @@
22 /* JavaScript for Special:MovePage */
33
44 jQuery( function( $ ) {
5 - $( '#wpReason' ).byteLimit();
 5+ $( '#wpReason, #wpNewTitleMain' ).byteLimit();
66 });

Follow-up revisions

RevisionCommit summaryAuthorDate
r110613[Special:MovePage] fix Title method usage. Need potential subpages included a...krinkle20:46, 2 February 2012
r112569Fix r110209: Move the invalid title check above the first use of the title ob...tstarling02:55, 28 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109990[Xml/Html] new method Html::namespaceSelector...krinkle03:01, 25 January 2012

Comments

#Comment by Catrope (talk | contribs)   20:06, 2 February 2012
+					Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getBaseText() ), array(

Is this use of getBaseText() deliberate? This means that if you supply ns=1 and title=User:Catrope/Foo , the form will be filled out with ns=Talk and title=User:Catrope , stripping the subpage component. If you want the full title text sans namespace, use $newTitle->getText() .

Marking fixme because this feels wrong and isn't explained anywhere.

#Comment by Krinkle (talk | contribs)   20:46, 2 February 2012
-					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(

You're right. I switched from "getPrefixedText" to "getBaseText" because namespace is separate now. I choose the wrong method.

Fixed in r110613 by using getText instead.

#Comment by Siebrand (talk | contribs)   12:08, 3 March 2012

Is it not possible to keep the old behaviour in effect? I think it's really annoying to have to operate a dropdown menu to move pages across namespaces. When I don't know the language, but do know the canonical namespace name, I now have to look at the source to find the correct namespace number and name before I'm able to move a page to the correct namespace.

#Comment by Nemo bis (talk | contribs)   21:57, 9 March 2012

Is this to blame for https://bugzilla.wikimedia.org/show_bug.cgi?id=34887 ? En passant, +1 on Siebrand.

#Comment by Catrope (talk | contribs)   17:36, 14 March 2012

Resetting to resolved. The revision itself is fine, other than the fact that people think the new UI is undesirable, but there's a bug filed about that in Bugzilla.

#Comment by Umherirrender (talk | contribs)   10:53, 18 March 2012
$( '#wpReason, #wpNewTitleMain' ).byteLimit();

makes problems, see bug 35294

#Comment by Krinkle (talk | contribs)   01:04, 19 March 2012

It doesn't make a problem, it triggers an existing problem. Thanks for discovering, fixed in r114116.

Status & tagging log