Steps to replicate the issue (include links if applicable):
- LocalSettings.php
$wgServer = "https://test.com"
- maintenance/update.php
public function execute() { print(wfExpandUrl( '/wiki/Main_Page', PROTO_INTERNAL ) . PHP_EOL); exit();
Run the code to trigger update.php
php maintenance/update.php --quick
What happens?:
- on REL1_39 branch > http:///wiki/Main_Page
- on REL1_37 branch > https://test.com/wiki/Main_Page
What should have happened instead?:
$wgInternalServer should fallback to $wgServer when not configured
Background & analysis
The investigation started with issue where we noticed view pages are not applying proper CDN cache but a 3600 hard coded s-maxage.
We then dig into the code changed and noticed that the handling of $wgInternalServer has changed, which caused matchURLForCDN to always return false, when $wgInternalServer is not defined.
Previous fallback code
// includes/GlobalFunctions.php } elseif ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) { // Make $wgInternalServer fall back to $wgServer if not set $serverUrl = $wgInternalServer; } else {
REL1_39 code
// includes/WebRequest.php public function matchURLForCDN( array $cdnUrls ) { $reqUrl = wfExpandUrl( $this->getRequestURL(), PROTO_INTERNAL ); $config = MediaWikiServices::getInstance()->getMainConfig(); if ( $config->get( MainConfigNames::CdnMatchParameterOrder ) ) { // Strict matching return in_array( $reqUrl, $cdnUrls, true ); } // includes/utils/UrlUtils.php if ( $defaultProto === PROTO_CANONICAL ) { $serverUrl = $this->canonicalServer; } elseif ( $defaultProto === PROTO_INTERNAL ) { $serverUrl = $this->internalServer; } else {
Software version (skip for WMF-hosted wikis like Wikipedia):
REL1_39
Workaround
Simplest workaround now is to have in LocalSettings.php
$wgInternalServer = $wgServer;