jenkins-bot has submitted this change and it was merged.

Change subject: Use LinkTarget in TitleValue only methods
......................................................................


Use LinkTarget in TitleValue only methods

Change-Id: Iee4b183ae54457d0c6cd3473f9fed3207742b54f
---
M includes/Title.php
M includes/title/MediaWikiPageLinkRenderer.php
M includes/title/MediaWikiTitleCodec.php
M includes/title/PageLinkRenderer.php
M includes/title/TitleFormatter.php
5 files changed, 44 insertions(+), 29 deletions(-)

Approvals:
  WMDE-Fisch: Looks good to me, but someone else must approve
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Title.php b/includes/Title.php
index f2a33e2..fdd773b 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -236,10 +236,21 @@
         * @return Title
         */
        public static function newFromTitleValue( TitleValue $titleValue ) {
+               return self::newFromLinkTarget( $titleValue );
+       }
+
+       /**
+        * Create a new Title from a LinkTarget
+        *
+        * @param LinkTarget $linkTarget Assumed to be safe.
+        *
+        * @return Title
+        */
+       public static function newFromLinkTarget( LinkTarget $linkTarget ) {
                return self::makeTitle(
-                       $titleValue->getNamespace(),
-                       $titleValue->getText(),
-                       $titleValue->getFragment() );
+                       $linkTarget->getNamespace(),
+                       $linkTarget->getText(),
+                       $linkTarget->getFragment() );
        }
 
        /**
diff --git a/includes/title/MediaWikiPageLinkRenderer.php 
b/includes/title/MediaWikiPageLinkRenderer.php
index 27574fa..07060b2 100644
--- a/includes/title/MediaWikiPageLinkRenderer.php
+++ b/includes/title/MediaWikiPageLinkRenderer.php
@@ -62,12 +62,12 @@
        /**
         * Returns the (partial) URL for the given page (including any section 
identifier).
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param array $params Any additional URL parameters.
         *
         * @return string
         */
-       public function getPageUrl( TitleValue $page, $params = array() ) {
+       public function getPageUrl( LinkTarget $page, $params = array() ) {
                // TODO: move the code from Linker::linkUrl here!
                // The below is just a rough estimation!
 
@@ -93,20 +93,24 @@
        /**
         * Returns an HTML link to the given page, using the given surface text.
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $linkTarget The link's target
         * @param string $text The link's surface text (will be derived from 
$page if not given).
         *
         * @return string
         */
-       public function renderHtmlLink( TitleValue $page, $text = null ) {
+       public function renderHtmlLink( LinkTarget $linkTarget, $text = null ) {
                if ( $text === null ) {
-                       $text = $this->formatter->getFullText( $page );
+                       $text = $this->formatter->getFullText( $linkTarget );
                }
 
                // TODO: move the logic implemented by Linker here,
                // using $this->formatter and $this->baseUrl, and
                // re-implement Linker to use a HtmlPageLinkRenderer.
-               $title = Title::newFromTitleValue( $page );
+               if ( $linkTarget instanceof Title ) {
+                       $title = $linkTarget;
+               } else {
+                       $title = Title::newFromLinkTarget( $linkTarget );
+               }
                $link = Linker::link( $title, htmlspecialchars( $text ) );
 
                return $link;
@@ -115,12 +119,12 @@
        /**
         * Returns a wikitext link to the given page, using the given surface 
text.
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param string $text The link's surface text (will be derived from 
$page if not given).
         *
         * @return string
         */
-       public function renderWikitextLink( TitleValue $page, $text = null ) {
+       public function renderWikitextLink( LinkTarget $page, $text = null ) {
                if ( $text === null ) {
                        $text = $this->formatter->getFullText( $page );
                }
diff --git a/includes/title/MediaWikiTitleCodec.php 
b/includes/title/MediaWikiTitleCodec.php
index c497865..1de4247 100644
--- a/includes/title/MediaWikiTitleCodec.php
+++ b/includes/title/MediaWikiTitleCodec.php
@@ -151,33 +151,33 @@
        /**
         * @see TitleFormatter::getText()
         *
-        * @param TitleValue $title
+        * @param LinkTarget $title
         *
         * @return string $title->getText()
         */
-       public function getText( TitleValue $title ) {
+       public function getText( LinkTarget $title ) {
                return $this->formatTitle( false, $title->getText(), '' );
        }
 
        /**
         * @see TitleFormatter::getText()
         *
-        * @param TitleValue $title
+        * @param LinkTarget $title
         *
         * @return string
         */
-       public function getPrefixedText( TitleValue $title ) {
+       public function getPrefixedText( LinkTarget $title ) {
                return $this->formatTitle( $title->getNamespace(), 
$title->getText(), '' );
        }
 
        /**
         * @see TitleFormatter::getText()
         *
-        * @param TitleValue $title
+        * @param LinkTarget $title
         *
         * @return string
         */
-       public function getFullText( TitleValue $title ) {
+       public function getFullText( LinkTarget $title ) {
                return $this->formatTitle( $title->getNamespace(), 
$title->getText(), $title->getFragment() );
        }
 
diff --git a/includes/title/PageLinkRenderer.php 
b/includes/title/PageLinkRenderer.php
index ca91f58..2ca5707 100644
--- a/includes/title/PageLinkRenderer.php
+++ b/includes/title/PageLinkRenderer.php
@@ -37,32 +37,32 @@
         *
         * @todo expand this to cover the functionality of Linker::linkUrl
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param array $params Any additional URL parameters.
         *
         * @return string
         */
-       public function getPageUrl( TitleValue $page, $params = array() );
+       public function getPageUrl( LinkTarget $page, $params = array() );
 
        /**
         * Returns an HTML link to the given page, using the given surface text.
         *
         * @todo expand this to cover the functionality of Linker::link
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param string $text The link's surface text (will be derived from 
$page if not given).
         *
         * @return string
         */
-       public function renderHtmlLink( TitleValue $page, $text = null );
+       public function renderHtmlLink( LinkTarget $page, $text = null );
 
        /**
         * Returns a wikitext link to the given page, using the given surface 
text.
         *
-        * @param TitleValue $page The link's target
+        * @param LinkTarget $page The link's target
         * @param string $text The link's surface text (will be derived from 
$page if not given).
         *
         * @return string
         */
-       public function renderWikitextLink( TitleValue $page, $text = null );
+       public function renderWikitextLink( LinkTarget $page, $text = null );
 }
diff --git a/includes/title/TitleFormatter.php 
b/includes/title/TitleFormatter.php
index aad8376..4edc5db 100644
--- a/includes/title/TitleFormatter.php
+++ b/includes/title/TitleFormatter.php
@@ -51,29 +51,29 @@
         *
         * @note Only minimal normalization is applied. Consider using 
TitleValue::getText() directly.
         *
-        * @param TitleValue $title The title to format
+        * @param LinkTarget $title The title to format
         *
         * @return string
         */
-       public function getText( TitleValue $title );
+       public function getText( LinkTarget $title );
 
        /**
         * Returns the title formatted for display, including the namespace 
name.
         *
-        * @param TitleValue $title The title to format
+        * @param LinkTarget $title The title to format
         *
         * @return string
         */
-       public function getPrefixedText( TitleValue $title );
+       public function getPrefixedText( LinkTarget $title );
 
        /**
         * Returns the title formatted for display, with namespace and fragment.
         *
-        * @param TitleValue $title The title to format
+        * @param LinkTarget $title The title to format
         *
         * @return string
         */
-       public function getFullText( TitleValue $title );
+       public function getFullText( LinkTarget $title );
 
        /**
         * Returns the name of the namespace for the given title.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iee4b183ae54457d0c6cd3473f9fed3207742b54f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: WMDE-Fisch <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to