Remove redundant null-handling for Title::newFromText
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 17 Nov 2015 01:53:30 +0000 (01:53 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 17 Nov 2015 01:53:30 +0000 (01:53 +0000)
* Linker: Follows-up 9ce5ca9886. null is already handled.

* PrefixSearch: Follows-up 337b1e2e. null is already handled.
  If other types are bassed, we want to find these.

* UploadBase: Follows-up 11f5ebec28. null is already handled.
  WebRequest::getVal($name) can only return string or null.

Change-Id: I3dc3b700cde735f5cd9d497f0867a2b4e3b61f46

includes/Linker.php
includes/PrefixSearch.php
includes/specials/SpecialMovepage.php

index b5e7e2f..842d276 100644 (file)
@@ -1464,19 +1464,17 @@ class Linker {
                                        $linkText = $text;
                                        $linkTarget = Linker::normalizeSubpageLink( $title, $match[1], $linkText );
 
-                                       if ( $linkTarget !== null ) {
-                                               $target = Title::newFromText( $linkTarget );
-                                               if ( $target ) {
-                                                       if ( $target->getText() == '' && !$target->isExternal()
-                                                               && !$local && $title
-                                                       ) {
-                                                               $newTarget = clone $title;
-                                                               $newTarget->setFragment( '#' . $target->getFragment() );
-                                                               $target = $newTarget;
-                                                       }
-
-                                                       $thelink = Linker::makeCommentLink( $target, $linkText . $inside, $wikiId ) . $trail;
+                                       $target = Title::newFromText( $linkTarget );
+                                       if ( $target ) {
+                                               if ( $target->getText() == '' && !$target->isExternal()
+                                                       && !$local && $title
+                                               ) {
+                                                       $newTarget = clone $title;
+                                                       $newTarget->setFragment( '#' . $target->getFragment() );
+                                                       $target = $newTarget;
                                                }
+
+                                               $thelink = Linker::makeCommentLink( $target, $linkText . $inside, $wikiId ) . $trail;
                                        }
                                }
                                if ( $thelink ) {
index f36635b..e328e9f 100644 (file)
@@ -368,10 +368,7 @@ abstract class PrefixSearch {
                        $ns = NS_MAIN; // if searching on many always default to main
                }
 
-               $t = null;
-               if ( is_string( $search ) ) {
-                       $t = Title::newFromText( $search, $ns );
-               }
+               $t = Title::newFromText( $search, $ns );
 
                $prefix = $t ? $t->getDBkey() : '';
                $dbr = wfGetDB( DB_SLAVE );
index 589c39f..e88aa1a 100644 (file)
@@ -77,11 +77,9 @@ class MovePageForm extends UnlistedSpecialPage {
                // Yes, the use of getVal() and getText() is wanted, see bug 20365
 
                $oldTitleText = $request->getVal( 'wpOldTitle', $target );
-               if ( is_string( $oldTitleText ) ) {
-                       $this->oldTitle = Title::newFromText( $oldTitleText );
-               }
+               $this->oldTitle = Title::newFromText( $oldTitleText );
 
-               if ( $this->oldTitle === null ) {
+               if ( !$this->oldTitle ) {
                        // Either oldTitle wasn't passed, or newFromText returned null
                        throw new ErrorPageError( 'notargettitle', 'notargettext' );
                }