Merge "Have Linker::linkUrl() accept LinkTarget"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 22 Apr 2016 11:46:16 +0000 (11:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 22 Apr 2016 11:46:16 +0000 (11:46 +0000)
1  2 
includes/Linker.php

diff --combined includes/Linker.php
@@@ -270,24 -270,23 +270,23 @@@ class Linker 
        /**
         * Returns the Url used to link to a Title
         *
-        * @param Title $target
+        * @param LinkTarget $target
         * @param array $query Query parameters
         * @param array $options
         * @return string
         */
-       private static function linkUrl( $target, $query, $options ) {
+       private static function linkUrl( LinkTarget $target, $query, $options ) {
                # We don't want to include fragments for broken links, because they
                # generally make no sense.
                if ( in_array( 'broken', $options, true ) && $target->hasFragment() ) {
-                       $target = clone $target;
-                       $target->setFragment( '' );
+                       $target = $target->createFragmentTarget( '' );
                }
  
                # If it's a broken link, add the appropriate query pieces, unless
                # there's already an action specified, or unless 'edit' makes no sense
                # (i.e., for a nonexistent special page).
                if ( in_array( 'broken', $options, true ) && empty( $query['action'] )
-                       && !$target->isSpecialPage() ) {
+                       && $target->getNamespace() !== NS_SPECIAL ) {
                        $query['action'] = 'edit';
                        $query['redlink'] = '1';
                }
                        $proto = PROTO_RELATIVE;
                }
  
-               $ret = $target->getLinkURL( $query, false, $proto );
+               $title = Title::newFromLinkTarget( $target );
+               $ret = $title->getLinkURL( $query, false, $proto );
                return $ret;
        }
  
  
  }
  
 -/**
 - * @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 );
 -      }
 -}