Ticket #2628 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

wordpress broken under apache mod_fastcgi with php ran as a cgi

Reported by: scruby Assigned to: anonymous
Priority: normal Milestone: 2.1
Component: General Version: 2.0.2
Severity: normal Keywords:
Cc:

Description

The error happens when php is run through fastCGI, and it is related to this problem that's reported on php bugs: http://bugs.php.net/bug.php?id=36705

To duplicate the problem, you need to compile php sapi/cli with fastcgi support, and run it under apache2/mod_fastcgi. This is what an entry in the error log looks like:

[Sat Apr 01 23:30:20 2006] [error] [client 66.215.220.80] FastCGI: comm with server "/var/www/fcgi-php/php" aborted: error parsing headers: duplicate header 'Status'

The relevant section of code is in wp-includes/functions.php

@header("Status: $header $text"); @header("HTTP/1.1 $header $text");

According to the suggestions on the php bug list, one workaround would be to rewrite this section of functions.php as follows:

if (substr(php_sapi_name(), 0, 3) == 'cgi') @header("Status: $header $text"); else @header("HTTP/1.1 $header $text");

I made this change myself, and it seems to make wordpress work both under mod_php and mod_fastcgi. I'm running apache 2.0.55/php 4.2.2 I've tested this code myself in both mod_cgi and mod_fastcgi configurations and it seems that all is well with it. I haven't tested this with php5, apache 1.3.x, or the extremely new apache versions above 2.0.

Attachments

functions.php.diff (0.5 kB) - added by leftjustified on 07/04/06 10:18:14.

Change History

04/03/06 12:25:28 changed by scruby

I need to add something to this:

http://bugs.php.net/bug.php?id=36705 rears its ugly head in several places. There's no reason in the world to send a header_status(200) in classes.php function handle_404. If you send nothing, php will assume you mean 200 by default. On the other hand, if you send status_header(200), then send header("Location: . . . ") you'll end up sending an extra Status: 302 header, and fastcgi will have an internal server error again. This breaks stuff like a click on the trackback link. So, in addition to the change mentioned above, you need to take out the status_header( 200 ); from classes.php

There's no point in doing status_header(200) anyway.

04/04/06 00:28:23 changed by ryan

When we didn't send the 200 people were ending up with 404s being sent instead. They were being mass de-listed from search engines.

06/14/06 00:22:16 changed by ryan

  • milestone changed from 2.0.2 to 2.0.4.

07/04/06 10:18:14 changed by leftjustified

  • attachment functions.php.diff added.

07/04/06 10:19:04 changed by leftjustified

  • keywords set to bg|has-patch, bg|needs-testing.

07/05/06 12:58:40 changed by dje

I have tested this patch under Wordpress 2.0.3 PHP Version 5.0.5-3 (with fastcgi)(and Apache/1.3.34 Debian) and it solves the header issue I was having, which was exactly as described in http://wordpress.org/support/topic/67416.

08/16/06 09:13:43 changed by hugoh

This patch did not work for me (using PHP5 with FastCGI). The way I solved it (which may not work for everybody) was by simply commenting '@header("Status: $header $text");' out.

09/21/06 01:29:27 changed by foolswisdom

  • keywords changed from bg|has-patch, bg|needs-testing to has-patch, needs-testing.
  • milestone changed from 2.0.4 to 2.2.

11/21/06 23:19:39 changed by abecciu

  • version changed from 2.0.2 to 2.0.
  • milestone changed from 2.2 to 2.0.

This patch works like a charm for me. It was tested on Apache 2.2.3 PHP/FastCGI 5.1.6.

11/22/06 00:16:50 changed by foolswisdom

  • version changed from 2.0 to 2.0.2.
  • milestone changed from 2.0 to 2.1.

abecciu what version of WordPress are you running ? Thank you.

11/22/06 00:17:03 changed by foolswisdom

  • milestone changed from 2.1 to 2.2.

11/22/06 05:13:27 changed by markjaquith

[4513] and [4514] may affect this. Please test with this change applied.

01/11/07 02:19:42 changed by foolswisdom

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.
  • milestone changed from 2.2 to 2.1.

Closing as FIXED for now.

No response to Mark's request for testing feedback. Current work in ticket:3528 may be relevant.