r98685 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98684‎ | r98685 | r98686 >
Date:16:24, 2 October 2011
Author:dantman
Status:deferred (Comments)
Tags:
Comment:
Separate the text and object forms of the target a bit so the text can be accessed if needed.
Modified paths:
  • /branches/pageoutput/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: branches/pageoutput/includes/SpecialPage.php
@@ -632,17 +632,25 @@
633633 }
634634
635635 /**
 636+ * Get the textual form of the target.
 637+ * This may be from the parameter or from the target in the request
 638+ */
 639+ public function getTargetText() {
 640+ $par = $this->getParameter();
 641+ if ( !is_null( $par ) ) {
 642+ return $par;
 643+ }
 644+ return $this->getRequest()->getVal( 'target', null );
 645+ }
 646+
 647+ /**
636648 * Get the target.
637649 * This may be from the parameter or from the target in the request
638650 * @note This cannot be getTarget because SpecialEmailUser has a static with that name
639651 */
640652 public function target() {
641653 if ( is_null( $this->mTargetParameter ) ) {
642 - $par = $this->getParameter();
643 - if ( !is_null( $par ) ) {
644 - return $par;
645 - }
646 - $target = $this->getRequest()->getVal( 'target', null );
 654+ $target = $this->getTargetText();
647655
648656 if ( $this instanceof SpecialTitleTarget ) {
649657 $target = Title::newFromURL( $target );

Comments

#Comment by Nikerabbit (talk | contribs)   17:10, 2 October 2011

Title::newFromURL??

         * THIS IS NOT THE FUNCTION YOU WANT. Use Title::newFromText().
#Comment by Nikerabbit (talk | contribs)   18:01, 2 October 2011

You trust random code more than a clear comment for the method itself?

#Comment by Dantman (talk | contribs)   18:12, 2 October 2011

Not random... I'm implementing a /$1 + &target= with the target being a Title, just like those... In fact I was originally hoping I'd migrate Whatlinkshere to be a targeted special page. So naturally I went with what patterns were being used by the code that works the way I want the code I'm writing to do.

Status & tagging log