Legoktm has uploaded a new change for review.

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

Change subject: Title::getLinkURL(): Allow expanding PROTO_RELATIVE too
......................................................................

Title::getLinkURL(): Allow expanding PROTO_RELATIVE too

Allow callers to get protocol-relative URLs by passing the
PROTO_RELATIVE constant. Since most callers don't pass in $proto, this
shouldn't change very much since the default of non-expanded is
effectively the same, but expanding to a protocol-relative URL when it
is not intended should still be safe.

A few callers that explicitly specified the default in core were also
updated.

Change-Id: I214f17aa6e8e30b647f21f0951fc3a15e87850c7
---
M includes/Title.php
M includes/linker/LinkRenderer.php
M includes/revisiondelete/RevDelArchivedFileItem.php
M includes/revisiondelete/RevDelFileItem.php
4 files changed, 7 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/70/292070/1

diff --git a/includes/Title.php b/includes/Title.php
index 4555f16..4da5fd7 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -1773,12 +1773,13 @@
         *
         * @param array $query
         * @param bool $query2
-        * @param string $proto Protocol to use; setting this will cause a full 
URL to be used
+        * @param string|int|bool $proto A PROTO_* constant on how the URL 
should be expanded,
+        *                               or false for no expansion
         * @see self::getLocalURL for the arguments.
         * @return string The URL
         */
-       public function getLinkURL( $query = '', $query2 = false, $proto = 
PROTO_RELATIVE ) {
-               if ( $this->isExternal() || $proto !== PROTO_RELATIVE ) {
+       public function getLinkURL( $query = '', $query2 = false, $proto = 
false ) {
+               if ( $this->isExternal() || $proto !== false ) {
                        $ret = $this->getFullURL( $query, $query2, $proto );
                } elseif ( $this->getPrefixedText() === '' && 
$this->hasFragment() ) {
                        $ret = $this->getFragmentForURL();
diff --git a/includes/linker/LinkRenderer.php b/includes/linker/LinkRenderer.php
index 432dcb2..c1ed248 100644
--- a/includes/linker/LinkRenderer.php
+++ b/includes/linker/LinkRenderer.php
@@ -391,16 +391,13 @@
        private function getLinkURL( LinkTarget $target, array $query = [] ) {
                // TODO: Use a LinkTargetResolver service instead of Title
                $title = Title::newFromLinkTarget( $target );
-               $proto = $this->expandUrls !== false
-                       ? $this->expandUrls
-                       : PROTO_RELATIVE;
                if ( $this->forceArticlePath ) {
                        $realQuery = $query;
                        $query = [];
                } else {
                        $realQuery = [];
                }
-               $url = $title->getLinkURL( $query, false, $proto );
+               $url = $title->getLinkURL( $query, false, $this->expandUrls );
 
                if ( $this->forceArticlePath && $realQuery ) {
                        $url = wfAppendQuery( $url, $realQuery );
diff --git a/includes/revisiondelete/RevDelArchivedFileItem.php 
b/includes/revisiondelete/RevDelArchivedFileItem.php
index e2bb516..f47a70b 100644
--- a/includes/revisiondelete/RevDelArchivedFileItem.php
+++ b/includes/revisiondelete/RevDelArchivedFileItem.php
@@ -107,8 +107,7 @@
                                                'target' => 
$this->list->title->getPrefixedText(),
                                                'file' => $file->getKey(),
                                                'token' => $user->getEditToken( 
$file->getKey() )
-                                       ],
-                                       false, PROTO_RELATIVE
+                                       ]
                                ),
                        ];
                }
diff --git a/includes/revisiondelete/RevDelFileItem.php 
b/includes/revisiondelete/RevDelFileItem.php
index 921fe5a..dca4d5a 100644
--- a/includes/revisiondelete/RevDelFileItem.php
+++ b/includes/revisiondelete/RevDelFileItem.php
@@ -215,8 +215,7 @@
                                                'target' => 
$this->list->title->getPrefixedText(),
                                                'file' => 
$file->getArchiveName(),
                                                'token' => $user->getEditToken( 
$file->getArchiveName() )
-                                       ],
-                                       false, PROTO_RELATIVE
+                                       ]
                                ),
                        ];
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I214f17aa6e8e30b647f21f0951fc3a15e87850c7
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