Skip to content

Commit 5319d0b

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()"
2 parents d7fe4e3 + 2b11d61 commit 5319d0b

File tree

15 files changed

+35
-27
lines changed

15 files changed

+35
-27
lines changed

docs/config-schema.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,12 +4111,12 @@ config-schema:
41114111
- //
41124112
type: array
41134113
description: |-
4114-
URL schemes that should be recognized as valid by wfParseUrl().
4114+
URL schemes that should be recognized as valid by UrlUtils::parse().
41154115
WARNING: Do not add 'file:' to this or internal file links will be broken.
41164116
Instead, if you want to support file links, add 'file://'. The same applies
41174117
to any other protocols with the same name as a namespace. See task T46011 for
41184118
more information.
4119-
@see \wfParseUrl
4119+
@see \MediaWiki\Utils\UrlUtils::parse()
41204120
CleanSignatures:
41214121
default: true
41224122
description: 'If true, removes (by substituting) templates in signatures.'

includes/Feed/AtomFeed.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function outHeader() {
7575

7676
/**
7777
* Atom 1.0 requests a self-reference to the feed.
78+
*
7879
* @return string
7980
*/
8081
private function getSelfUrl() {
@@ -84,6 +85,7 @@ private function getSelfUrl() {
8485

8586
/**
8687
* Output a given item.
88+
*
8789
* @param FeedItem $item
8890
*/
8991
public function outItem( $item ) {

includes/MainConfigSchema.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6430,14 +6430,14 @@ public static function getDefaultMetaNamespace( $sitename ): string {
64306430
];
64316431

64326432
/**
6433-
* URL schemes that should be recognized as valid by wfParseUrl().
6433+
* URL schemes that should be recognized as valid by UrlUtils::parse().
64346434
*
64356435
* WARNING: Do not add 'file:' to this or internal file links will be broken.
64366436
* Instead, if you want to support file links, add 'file://'. The same applies
64376437
* to any other protocols with the same name as a namespace. See task T46011 for
64386438
* more information.
64396439
*
6440-
* @see \wfParseUrl
6440+
* @see \MediaWiki\Utils\UrlUtils::parse()
64416441
*/
64426442
public const UrlProtocols = [
64436443
'default' => [

includes/Request/ContentSecurityPolicy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,12 @@ private function prepareUrlForCSP( $url ) {
334334
// A schema source (e.g. blob: or data:)
335335
return $url;
336336
}
337-
$bits = wfParseUrl( $url );
337+
$bits = wfGetUrlUtils()->parse( $url );
338338
if ( !$bits && strpos( $url, '/' ) === false ) {
339339
// probably something like example.com.
340340
// try again protocol-relative.
341341
$url = '//' . $url;
342-
$bits = wfParseUrl( $url );
342+
$bits = wfGetUrlUtils()->parse( $url );
343343
}
344344
if ( $bits && isset( $bits['host'] )
345345
&& $bits['host'] !== $this->mwConfig->get( MainConfigNames::ServerName )

includes/WikiMap/WikiMap.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private static function getWikiWikiReferenceFromSites( $wikiID ) {
9595
return null;
9696
}
9797

98-
$urlParts = wfParseUrl( $site->getPageUrl() );
99-
if ( $urlParts === false || !isset( $urlParts['path'] ) || !isset( $urlParts['host'] ) ) {
98+
$urlParts = wfGetUrlUtils()->parse( $site->getPageUrl() );
99+
if ( $urlParts === null || !isset( $urlParts['path'] ) || !isset( $urlParts['host'] ) ) {
100100
// We can't create a meaningful WikiReference without URLs
101101
return null;
102102
}
@@ -208,14 +208,14 @@ static function () {
208208
$wikiId = self::getCurrentWikiId();
209209
$infoMap[$wikiId] = [
210210
'url' => $wgCanonicalServer,
211-
'parts' => wfParseUrl( $wgCanonicalServer )
211+
'parts' => wfGetUrlUtils()->parse( $wgCanonicalServer )
212212
];
213213

214214
foreach ( $wgLocalDatabases as $wikiId ) {
215215
$wikiReference = self::getWiki( $wikiId );
216216
if ( $wikiReference ) {
217217
$url = $wikiReference->getCanonicalServer();
218-
$infoMap[$wikiId] = [ 'url' => $url, 'parts' => wfParseUrl( $url ) ];
218+
$infoMap[$wikiId] = [ 'url' => $url, 'parts' => wfGetUrlUtils()->parse( $url ) ];
219219
}
220220
}
221221

@@ -238,8 +238,8 @@ public static function getWikiFromUrl( $url ) {
238238
return self::getCurrentWikiId();
239239
}
240240

241-
$urlPartsCheck = wfParseUrl( $url );
242-
if ( $urlPartsCheck === false ) {
241+
$urlPartsCheck = wfGetUrlUtils()->parse( $url );
242+
if ( $urlPartsCheck === null ) {
243243
return false;
244244
}
245245

includes/deferred/CdnCacheUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private static function naivePurge( array $urls ) {
292292
$reqs = [];
293293
foreach ( $urls as $url ) {
294294
$url = self::expand( $url );
295-
$urlInfo = wfParseUrl( $url );
295+
$urlInfo = wfGetUrlUtils()->parse( $url ) ?? false;
296296
$urlHost = strlen( $urlInfo['port'] ?? '' )
297297
? IPUtils::combineHostAndPort( $urlInfo['host'], (int)$urlInfo['port'] )
298298
: $urlInfo['host'];

includes/editpage/IntroMessageBuilder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,12 @@ private function addEditIntro(
413413
}
414414

415415
if ( !$page->exists() ) {
416-
$helpLink = $this->urlUtils->expand( Skin::makeInternalOrExternalUrl(
417-
$localizer->msg( 'helppage' )->inContentLanguage()->text()
418-
), PROTO_CURRENT );
416+
$helpLink = $this->urlUtils->expand(
417+
Skin::makeInternalOrExternalUrl(
418+
$localizer->msg( 'helppage' )->inContentLanguage()->text()
419+
),
420+
PROTO_CURRENT
421+
);
419422
if ( $performer->getUser()->isRegistered() ) {
420423
$messages->add(
421424
$localizer->msg( 'newarticletext', $helpLink ),

includes/http/MWHttpRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ protected function proxySetup() {
250250
* @param string $proxy URL of proxy
251251
*/
252252
protected function setReverseProxy( string $proxy ) {
253-
$parsedProxy = $this->urlUtils->parse( $proxy ) ?? false;
254-
if ( $parsedProxy === false ) {
253+
$parsedProxy = $this->urlUtils->parse( $proxy );
254+
if ( $parsedProxy === null ) {
255255
throw new InvalidArgumentException( "Invalid reverseProxy configured: $proxy" );
256256
}
257257
// Set the current host in the Host header
@@ -264,7 +264,7 @@ protected function setReverseProxy( string $proxy ) {
264264
} else {
265265
unset( $this->parsedUrl['port'] );
266266
}
267-
$this->url = UrlUtils::assemble( (array)$this->parsedUrl );
267+
$this->url = UrlUtils::assemble( $this->parsedUrl );
268268
// Mark that we're already using a proxy
269269
$this->noProxy = true;
270270
}

includes/jobqueue/jobs/ThumbnailRenderJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function hitThumbUrl( LocalFile $file, $transformParams ) {
101101
}
102102

103103
if ( $uploadThumbnailRenderHttpCustomDomain ) {
104-
$parsedUrl = wfParseUrl( $thumbUrl );
104+
$parsedUrl = wfGetUrlUtils()->parse( $thumbUrl );
105105

106106
if ( !isset( $parsedUrl['path'] ) || $parsedUrl['path'] === '' ) {
107107
$this->setLastError( __METHOD__ . ": invalid thumb URL: $thumbUrl" );

includes/parser/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,8 +2271,9 @@ public static function getExternalLinkRel( $url = false, LinkTarget $title = nul
22712271
$noFollowNsExceptions = $mainConfig->get( MainConfigNames::NoFollowNsExceptions );
22722272
$noFollowDomainExceptions = $mainConfig->get( MainConfigNames::NoFollowDomainExceptions );
22732273
$ns = $title ? $title->getNamespace() : false;
2274-
if ( $noFollowLinks && !in_array( $ns, $noFollowNsExceptions )
2275-
&& !wfMatchesDomainList( $url, $noFollowDomainExceptions )
2274+
if (
2275+
$noFollowLinks && !in_array( $ns, $noFollowNsExceptions )
2276+
&& !wfGetUrlUtils()->matchesDomainList( (string)$url, $noFollowDomainExceptions )
22762277
) {
22772278
return 'nofollow';
22782279
}

0 commit comments

Comments
 (0)