Page MenuHomePhabricator

Fix: detectServer appends default ports that should be omitted
Closed, ResolvedPublic

Description

In MediaWiki 1.41.0 the function WebRequest::detectServer() started to generate server URL strings containing default ports such as 80 for http and 443 for https.

Before 1.41.0: https://my.wiki
After 1.41.0: https://my.wiki:443

detectServer() uses IPUtils::combineHostAndPort() to build the URL. The latter function has actually a mechanism built in that intends to omit standard ports, so the new behavior in MW 1.41.0 seems unintended.

As this broke WDQS over here in our Wikibase Suite bundle, I investigated the cause.

MediaWiki 1.41.0 updates IPUtils from 4 to 5. With this update, there was a change that compares the port now via === instead of ==. (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/libs/IPUtils/+/e68cf6a14efe083e77723d686d5381ed9e64dc73%5E%21/#F1 Line 383) The new behavior is correct, as the function expects an int. MediaWiki passes in a string though. This bug was hidden with IPUtils 4, but is triggered now in IPUtils 5.

The patch is ready and I will upload it to gerrit.

Event Timeline

roti_WMDE renamed this task from Upstream the MW 1.41 detectServer fix to Fix: detectServer appends default ports that should be omitted.Mar 26 2024, 1:44 PM
roti_WMDE added a project: MediaWiki-General.
roti_WMDE updated the task description. (Show Details)

Change #1014512 had a related patch set uploaded (by Robert Timm; author: Robert Timm):

[mediawiki/core@master] fix: detectServer appends default ports that should be omitted

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

Change #1014512 merged by jenkins-bot:

[mediawiki/core@master] WebRequest: detectServer appends default ports that should be omitted

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

Change #1015191 had a related patch set uploaded (by Reedy; author: Robert Timm):

[mediawiki/core@REL1_41] WebRequest: detectServer appends default ports that should be omitted

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

Change #1015191 merged by jenkins-bot:

[mediawiki/core@REL1_41] WebRequest: detectServer appends default ports that should be omitted

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