Last modified: 2013-02-09 14:58:14 UTC
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
Hi Etienne! Sorry that nobody has taken a look at this report yet and given feedback. As the HTTP_HOST code which existed in MediaWiki 1.9 : https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blame;f=includes/DefaultSettings.php;hb=1ceeed99432e2715b958df4810a94d3e8f4ea2fa#l43 does not exist in the current codebase anymore: https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blame;f=includes/DefaultSettings.php;h=6a4f6a60a37f40e063585f16b0abe77472c6a7f8;hb=HEAD I assume that the problem and also the provided workaround is obsolete nowadays. If it's not, please tell us which MediaWiki version you use. Also see the comments about "CGI mode" in that source file.
(In reply to comment #1) > As the HTTP_HOST code which existed in MediaWiki 1.9 : > https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blame; > f=includes/DefaultSettings.php; > hb=1ceeed99432e2715b958df4810a94d3e8f4ea2fa#l43 > does not exist in the current codebase anymore: > https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blame; > f=includes/DefaultSettings.php;h=6a4f6a60a37f40e063585f16b0abe77472c6a7f8; > hb=HEAD that's because it got moved to WebRequest::detectServer... However, with that said, newer versions of MW set the host (and port) at install time, so this issue is much less likely to strike [while, I suppose if the installer mis-detects that would still cause badness]. If you are still having problems with host/port auto-detection the correct work around is to set $wgServer = "http://mywebsite.com:8080"; or whatever your server is, in you LocalSettings.php (and still re-open the bug, because the auto-detection should work)
Better late than never ;-) And I don't use version 1.9 anymore. However thank you for feedback !