• Resolved davidljung

    (@davidljung)


    I’ve never seen this before, but I’m running WP 3.1 with multi-site enabled. When I access the site, everything looks normal, but if I examine the response header of the initial page access, the response header is actually 500 Internal Server Error, even though the body of the response contains the correct page code!

    Firefox 4 and Chrome both ignore the 500 response code and render the page without complaint! All the secondary requests triggered by the page (to load CSS, JS, images etc etc) all have correct response codes (200).

    I can examine the headers with dev tools from within both Chrome and FF and they show the 500 code, even though they’re showing the page content. If I use curl, I also get the content and 500 response code header. When I attempt to use the W3C validator service, it complains (as I’d think all the clients should!).

    Anyone else seen this behaviour? Any idea how I can go about tracking it down – there in WP the header is being set (so I can figure out why). Is it possible that is a default and it just isn’t getting updated to 200 before the page is output or something?

    PHP 5.3.x, Apache 2, Ubuntu, pretty standard setup.

    Thanks!
    -David.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter davidljung

    (@davidljung)

    So, PHP’s headers_sent() function was useless, just reporting the line when the top-level call to render the template was made.

    by disabling all plugins, I’ve narrowed it to one plugin. Now, searching the source for header( .. 500 ..) I’ve located all the places in WP where it calls that and put in debug code around them – but they are *never* called with a status of 500. The header *is* being set to 200, but the response from Apache is coming back 500!

    So, what could be causing it? Any gurus out there?

    Appreciate any clues anyone might have.
    Thanks.

    Yeah, I’ve seen this on goDaddy servers, especially when visiting the signup page. Even the top borwser bar will say 404 but the page renders fine.

    Thread Starter davidljung

    (@davidljung)

    ok, I’ve figured it out. There was some invalid PHP being passed to an eval() call. That PHP parser error within eval() was causing the status to be set to 500, even though execution proceeded just fine and rendered the page.

    (Specifically, there was a function taking a string expression to be evaluated. It was ‘sanitizing’ it making it safe to execute as PHP – just restricting it to simple math expressions – then passing it to eval wrapped in “return ($expr);”. Problem was it wasn’t considering when $expr was the empty string and since “return ();” isn’t valid, that was causing it).

    was it in core or a plugin?

    Thread Starter davidljung

    (@davidljung)

    A plugin. (not one of the public ones).

    The php.net documentation for eval() claims it’ll halt script execution if the PHP isn’t valid, but that isn’t true in this case (it just returned FALSE instead).

    Thanks.

    I’ve got the same problem and can’t find a solution. What did you do to solve it?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Andreas – When a topic is flagged resolved, you shouldn’t post to it anymore since we don’t often monitor them.

    Turn off ALL your plugins and test again. If the problem persists, or you need more help, open a NEW topic all for yourself 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Weird: response hdr 500 Internal error, but pages render anyway’ is closed to new replies.