Merge "Have Linker::normaliseSpecialPage() accept LinkTarget objects"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 26 Apr 2016 19:30:38 +0000 (19:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 26 Apr 2016 19:30:38 +0000 (19:30 +0000)
1  2 
includes/Linker.php

diff --combined includes/Linker.php
@@@ -446,19 -446,19 +446,19 @@@ class Linker 
        }
  
        /**
-        * @param Title $title
-        * @return Title
+        * @param LinkTarget $target
+        * @return LinkTarget|Title You will get back the same type you passed in, or a Title object
         */
-       static function normaliseSpecialPage( Title $title ) {
-               if ( $title->isSpecialPage() ) {
-                       list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+       static function normaliseSpecialPage( LinkTarget $target ) {
+               if ( $target->getNamespace() == NS_SPECIAL ) {
+                       list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $target->getDBkey() );
                        if ( !$name ) {
-                               return $title;
+                               return $target;
                        }
-                       $ret = SpecialPage::getTitleFor( $name, $subpage, $title->getFragment() );
+                       $ret = SpecialPage::getTitleFor( $name, $subpage, $target->getFragment() );
                        return $ret;
                } else {
-                       return $title;
+                       return $target;
                }
        }
  
  
  }
  
 -/**
 - * @since 1.18
 - */
 -class DummyLinker {
 -
 -      /**
 -       * Use PHP's magic __call handler to transform instance calls to a dummy instance
 -       * into static calls to the new Linker for backwards compatibility.
 -       *
 -       * @param string $fname Name of called method
 -       * @param array $args Arguments to the method
 -       * @return mixed
 -       */
 -      public function __call( $fname, $args ) {
 -              return call_user_func_array( [ 'Linker', $fname ], $args );
 -      }
 -}