GlobalFunctions: Unbreak handling of '?0' query in wfAssembleUrl()

Follows-up Ief9c15cc8fe0fcae07d2c.

Bug: T268852
Change-Id: I5ddac943aad4d634ea20cd4d4cb21d1c857c05fd
This commit is contained in:
Timo Tijhof 2020-11-26 23:45:45 +00:00
parent 44516c671c
commit ea586cfa2e
2 changed files with 7 additions and 7 deletions

View file

@ -614,7 +614,7 @@ function wfAssembleUrl( $urlParts ) {
$result .= $urlParts['path'];
}
if ( isset( $urlParts['query'] ) && $urlParts['query'] ) {
if ( isset( $urlParts['query'] ) && $urlParts['query'] !== '' ) {
$result .= '?' . $urlParts['query'];
}

View file

@ -67,9 +67,9 @@ class WfAssembleUrlTest extends MediaWikiUnitTestCase {
$cases = [];
foreach ( $schemes as $scheme => $schemeParts ) {
foreach ( $hosts as $host => $hostParts ) {
foreach ( [ '', '/path' ] as $path ) {
foreach ( [ '', 'query' ] as $query ) {
foreach ( [ '', 'fragment' ] as $fragment ) {
foreach ( [ '', '/', '/0', '/path' ] as $path ) {
foreach ( [ '', '0', 'query' ] as $query ) {
foreach ( [ '', '0', 'fragment' ] as $fragment ) {
$parts = array_merge(
$schemeParts,
$hostParts
@ -78,14 +78,14 @@ class WfAssembleUrlTest extends MediaWikiUnitTestCase {
$host .
$path;
if ( $path ) {
if ( $path !== '' ) {
$parts['path'] = $path;
}
if ( $query ) {
if ( $query !== '' ) {
$parts['query'] = $query;
$url .= '?' . $query;
}
if ( $fragment ) {
if ( $fragment !== '' ) {
$parts['fragment'] = $fragment;
$url .= '#' . $fragment;
}