r41343 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41342‎ | r41343 | r41344 >
Date:11:51, 28 September 2008
Author:nikerabbit
Status:old (Comments)
Tags:
Comment:
* Do not pass objects to functions that don't take them
Modified paths:
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -54,12 +54,13 @@
5555 * @ingroup SpecialPage
5656 */
5757 class MovePageForm {
58 - var $oldTitle, $newTitle, $reason; # Text input
59 - var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects;
 58+ var $oldTitle, $newTitle; # Objects
 59+ var $reason; # Text input
 60+ var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects; # Checks
6061
6162 private $watch = false;
6263
63 - function MovePageForm( $oldTitle, $newTitle ) {
 64+ function __construct( $oldTitle, $newTitle ) {
6465 global $wgRequest;
6566 $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
6667 $this->oldTitle = $oldTitle;
@@ -83,16 +84,19 @@
8485 $skin = $wgUser->getSkin();
8586
8687 $oldTitleLink = $skin->makeLinkObj( $this->oldTitle );
87 - $oldTitle = $this->oldTitle->getPrefixedText();
8888
89 - $wgOut->setPagetitle( wfMsg( 'move-page', $oldTitle ) );
 89+ $wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) );
9090 $wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) );
9191
92 - if( $this->newTitle == '' ) {
 92+ $newTitle = $this->newTitle;
 93+
 94+ if( !$newTitle ) {
9395 # Show the current title as a default
9496 # when the form is first opened.
95 - $newTitle = $oldTitle;
96 - } else {
 97+ $newTitle = $this->oldTitle;
 98+ }
 99+ // WTF is this doing, passing title *object* to newFromUrl()??
 100+ /*else {
97101 if( empty($err) ) {
98102 $nt = Title::newFromURL( $this->newTitle );
99103 if( $nt ) {
@@ -105,11 +109,10 @@
106110 }
107111 }
108112 }
109 - $newTitle = $this->newTitle;
110 - }
 113+ }*/
111114
112115 if ( !empty($err) && $err[0] == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
113 - $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle );
 116+ $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
114117 $movepagebtn = wfMsg( 'delete_and_move' );
115118 $submitVar = 'wpDeleteAndMove';
116119 $confirm = "
@@ -172,8 +175,8 @@
173176 Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
174177 "</td>
175178 <td class='mw-input'>" .
176 - Xml::input( 'wpNewTitle', 40, $newTitle, array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
177 - Xml::hidden( 'wpOldTitle', $oldTitle ) .
 179+ Xml::input( 'wpNewTitle', 40, $newTitle->getPrefixedText(), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
 180+ Xml::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
178181 "</td>
179182 </tr>
180183 <tr>
@@ -215,7 +218,7 @@
216219 <tr>
217220 <td></td>
218221 <td class=\"mw-input\">" .
219 - Xml::checkLabel( wfMsgHtml(
 222+ Xml::checkLabel( wfMsg(
220223 $this->oldTitle->hasSubpages()
221224 ? 'move-subpages'
222225 : 'move-talk-subpages'

Follow-up revisions

RevisionCommit summaryAuthorDate
r41911Fix error display on invalid destination title on GET, e.g. with URL /wiki/Sp...tstarling01:02, 10 October 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   01:36, 1 October 2008

The big ol /* ... */ around a code block worries me a bit. Has this been fixed up?

#Comment by Tim Starling (talk | contribs)   00:47, 10 October 2008

I'd prefer it if people actually understood code before they changed it, it would save some review work.

#Comment by Tim Starling (talk | contribs)   00:51, 10 October 2008

It's a bug from r35990, $this->newTitle was changed from text to object, but not all references were fixed.

#Comment by Tim Starling (talk | contribs)   01:02, 10 October 2008

Resolved in r41911.

Status & tagging log