Last modified: 2013-02-09 14:58:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 9330 - Error with non standard http port under apache and php in cgi-mode
Error with non standard http port under apache and php in cgi-mode
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
PC Windows XP
: Low major (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2007-03-18 23:49 UTC by Etienne Durup
Modified: 2013-02-09 14:58 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Etienne Durup 2007-03-18 23:49: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 :

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 ) {
  $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

(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.
Comment 1 Andre Klapper 2013-01-29 20:47:51 UTC
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 :;a=blame;f=includes/DefaultSettings.php;hb=1ceeed99432e2715b958df4810a94d3e8f4ea2fa#l43
does not exist in the current codebase anymore:;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.
Comment 2 Bawolff (Brian Wolff) 2013-02-06 15:49:16 UTC
(In reply to comment #1)

> As the HTTP_HOST code which existed in MediaWiki 1.9 :
> f=includes/DefaultSettings.php;
> hb=1ceeed99432e2715b958df4810a94d3e8f4ea2fa#l43
> does not exist in the current codebase anymore:
> 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 = ""; or whatever your server is, in you LocalSettings.php (and still re-open the bug, because the auto-detection should work)
Comment 3 Etienne Durup 2013-02-09 14:58:14 UTC
Better late than never ;-)
And I don't use version 1.9 anymore.
However thank you for feedback !

Note You need to log in before you can comment on or make changes to this bug.