Author: etienne.durup
Description:
I run Apache2 on Windows, with PHP 5.2.0 in cgi mode (php-cgi.exe).
The Apache localhost server listen ports 2710, 2711 and 2712 (and IIS listen on 80).
URL of my MediaWiki :
http://localhost:2712/mediawiki/index.php?title=Accueil
In this case, $_SERVER[HTTP_PORT] gives always 80.
When I edit a page :
- editing goes right
- also good with previsualisation
- but "save" goes back to http://localhost/mediawiki/.... and fail
The addition of following lines next line 70 in includes/DefaultSettings.php
solves the problem :
Get the true http host port if exists even in cgi mode
if ( isset($_SERVER['HTTP_HOST'] )
&& strpos($_SERVER['HTTP_HOST'],':') !==false ) { preg_match('/.*\:(.*)/',$_SERVER['HTTP_HOST'],$matches); $wgServerHostPort = $matches[1]; $_SERVER['SERVER_PORT'] = $wgServerHostPort;
}
I can't verify if this creates a new bug in other cases. I don't believe that
but... who knows ?
I've verified that this algorithm goes right under apache and IIS in cgi-mode
with php5 and php4 (with other app).
Make a simple test in many web server configurations and you'll get big surprises :
foreach ($_SERVER as $key=>$val) {
echo "$key = $val<br>";
}
Because that, I don't use $SERVER['SCRIPT_NAME'], $_SERVER['SERVER_PORT'],
$SERVER['SCRIPT_FILENAME'] anymore. It's not portable and this breaks ascendant
compatibility.
(For example, the first one with PHP4 returns /php/php.exe in cgi-mode ; with
PHP5 it is corrected and returns the php script path)
My two cents.
Regards
Version: 1.9.x
Severity: major
OS: Windows XP
Platform: PC