From: Kunal Mehta Date: Wed, 1 Jun 2016 03:11:31 +0000 (-0700) Subject: Title::getLinkURL(): Allow expanding PROTO_RELATIVE too X-Git-Tag: 1.31.0-rc.0~6324^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=5e11a28e7a75af86d7547857bb74ce1c216a3673;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/Title.php b/includes/Title.php index 4555f16d9b..bae3a7684c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1773,12 +1773,13 @@ class Title implements LinkTarget { * * @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 (default) 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 432dcb23dc..c1ed2487f8 100644 --- a/includes/linker/LinkRenderer.php +++ b/includes/linker/LinkRenderer.php @@ -391,16 +391,13 @@ class LinkRenderer { 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 e2bb51664f..f47a70b562 100644 --- a/includes/revisiondelete/RevDelArchivedFileItem.php +++ b/includes/revisiondelete/RevDelArchivedFileItem.php @@ -107,8 +107,7 @@ class RevDelArchivedFileItem extends RevDelFileItem { '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 921fe5a635..dca4d5a6bf 100644 --- a/includes/revisiondelete/RevDelFileItem.php +++ b/includes/revisiondelete/RevDelFileItem.php @@ -215,8 +215,7 @@ class RevDelFileItem extends RevDelItem { 'target' => $this->list->title->getPrefixedText(), 'file' => $file->getArchiveName(), 'token' => $user->getEditToken( $file->getArchiveName() ) - ], - false, PROTO_RELATIVE + ] ), ]; }