Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284417

Change subject: Have Linker::linkUrl() accept LinkTarget
......................................................................

Have Linker::linkUrl() accept LinkTarget

This is a private function so it doesn't really make much of a
difference, but will allow further refactoring.

Change-Id: Idacad7b1bd4776c04659ed9af64540d6ce4b2f28
---
M includes/Linker.php
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/284417/1

diff --git a/includes/Linker.php b/includes/Linker.php
index 4ba3a75..799b8b8 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -270,24 +270,23 @@
        /**
         * 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';
                }
@@ -300,7 +299,8 @@
                        $proto = PROTO_RELATIVE;
                }
 
-               $ret = $target->getLinkURL( $query, false, $proto );
+               $title = Title::newFromLinkTarget( $target );
+               $ret = $title->getLinkURL( $query, false, $proto );
                return $ret;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/284417
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idacad7b1bd4776c04659ed9af64540d6ce4b2f28
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to