Bizarre phantom bug (Calling a PHP script from an Apache "Action" directive)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
(Apache/2.0.55, PHP/4.4.1)
I am using an "Action" directive in my Apache configuration to map a
certain file type (by means of AddType and AddHandler) to a PHP script.
I wasn't sure if this would work, since the Apache docs say the Action
directive is for mapping a handler name to a CGI script in particular.
But it seemed to work at first.

Then a mysterious bug arose: Sometimes it works perfectly, and other
times the output is a totally blank page. It seems that if I haven't
viewed a page for a while, it chooses to do one of these at random
(though it is blank more often than not), and then it persists in the
same behaviour until I reload it many times. (That is, usually a page
appearing blank will eventually display if I reload it many times;
however, only rarely will a correctly-displayed page regress to
appearing blank after reloads.) Checking with `curl -i', it would
appear to a client program that the request was perfectly successful:
all the headers are there (with the correct content-type), it has an
HTTP/1.1 200 OK line, and so on (and there's nothing unusual in the
server's access or error logs), except Content-length is 0, and there
is indeed no content at all after the two newlines.

WTF?? Since when do computers behave non-deterministically? I should
hope, if a program is not going to behave correctly, that it at least
do so predictably and consistently. That would make debugging it much
easier. But what am I to make of this Schrodinger's Bug? How do I even
approach the debugging process?

(Also, if anyone could suggest a workaround, an alternate method of
having a PHP script handle files with a certain extension, then that
would be just as welcome. Though I'd like to stay within mod_php,
avoiding a CGI-based technique, because I'd prefer to not start a
process every time these pages are requested.)

-- Adam Atlas

Re: Bizarre phantom bug (Calling a PHP script from an Apache "Action" directive)

It's unclear from your message whether your flaky page delivery issue
arises from the resultant page being cached or the page being corrupt
(or something else), but two ideas follow.  In any case, I suggest you
put manual logging into the actual .php file used to generate the
returned page (so that you are 100% certain it is being run.  Just
append the date/time and any miscellaneous stats to a fixed file).
Secondly, as far as preventing cacheing of the pages, I have a little
discussion of possible headers to be aware of at

Csaba Gabor from Vienna

Adam Atlas wrote:
Quoted text here. Click to load it

Site Timeline