Why is $_SERVER[] Considered a “Class?”

There seems to be a minor bug/glitch in our Request_URI for Windows that we can't figure out, so if anyone has any idea, please give us a holler, or post below if you like. Under times of high load (and sometimes without), PHP complely crashes and dies until the worker process is restarted with Using $this not in object context as the "die message" that shows up for all requests. However, our script doesn't use a class, and makes no calls to one either.

The actual line in question is

[sourcecode language='php'] if (isset($_SERVER['HTTP_REQUEST_URI'])){[/sourcecode]

And there doesn't seem to be any real reason for this to error out. isset is a global function, and $_SERVER['HTTP_REQUEST_URI'] is a global variable. It's an illogical error that shouldn't happen; especially seeing as it will work for days on end, then suddenly die. The fact that it totally kills PHP on the server should be a clue that a bug is indeed present, but there's a little problem: it's not reproducible.

If you can't reproduce a bug and you're not the developer, you might as well forget about getting it fixed. If it's not reproducible, it's unfixable. There's a possibility however, that this is related to PHP Bug #39819 which discusses a segfault under NetBSD when this error occurs - but it's not the same. A listing of all similar bugs doesn't seem to turn anything up. We're experiencing it on a Windows Server 2003 SP1 + IIS 6 + PHP 5.20, and have had reports from users on similar setups.



Leave a Reply  •  About to Ask for Help?  •  Subscribe to Our Feed

3 Responses to “ Why is $_SERVER[] Considered a “Class?” ”


  1. 1Michael DaleDec. 20th, 2006 at 10:23 am

    Why don't you try this:

    if (array_key_exists('HTTP_REQUEST_URI', $_SERVER)) {

  2. 2Michael DaleDec. 20th, 2006 at 10:25 am

    Question.

    Why is this site so slow? You're doing 50(!!!) queries per page! Much higher than a standard Wordpress install.

     

  3. 3Computer GuruDec. 20th, 2006 at 12:14 pm

    I think that should work. I was wondering what would happen if the array didn't exist and that funtion was used - normally that wouldn't be a concern for $_SERVER, but seeing as something is obviously wrong anyway.....

    I think this just might be the bug (from the PHP docs):

    isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does.

    I'll certainly look into it once I get home.

    As for your other question: it's probably all of the plugins + the theme. K2 is query-heavy, and there are about 55 plugins currently installed - though most don't interface with the database. NeoSmart is running WP 2.1 SVN, once it htis Beta (currently at alpha 3), the site will undergo some major mainteance and cleanup -  we just want to be sure it won't be wasted if WP 2.1 beta breaks any of it, but I don't think so, it's more or less "done breaking things."

    Thanks for the suggestion, at the moment I changed the script (on our server) to not check if it's set, haven't had any problems since, so hopefully I can make this change to the main file as well.

Leave a Reply