“Apache HTTP Service has stopped working” with WP Query in WordPress 2.9.2

The question:

When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an “Apache HTTP Service has stopped working” error

$cat=get_cat_ID('top-menu');
$catHidden=get_cat_ID('hidden');
$myqueryCurrent = new WP_Query();
$myqueryCurrent->query(array('cat'=>"$cat,-$catHidden",'post__not_in'=>get_option('sticky_posts')));

Do you see something in that 4th line that’s incompatible with WP 2.9.2? The code runs fine on the same server under WP 3.0.4

Here’s the details of the error:

Problem signature:
Problem Event Name: APPCRASH
Application Name: httpd.exe
Application Version: 2.2.14.0
Application Timestamp: 4aeb9704
Fault Module Name: php5ts.dll
Fault Module Version: 5.3.1.0

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Executing the code you posted results in a crash inside the PHP module. I assume you’re running PHP as module inside apache on windows, if the module crashes, apache crashes as well.

Ensure that you’re using the right PHP modules here. Are you sure you need the Thread-Safe variant of PHP for apache? Those are reported to not run stable under windows IIRC.

So this might not be related to the wordpress version but to the server configuration.

Hope this answer helps a bit tackling things down.

Method 2

Realise this old now, but this may help people finding this via Google:

I had problems with Apache dying when running similar code within a function called by the pre_get_posts hook. Problem was I missed the conditional:

$query->is_main_query()

meaning it was doing work for all the queries, not just the main one. Adding that fixed the problem for me. The full conditional I use is (then other code above below that:

if ( ! is_category() || ! $query->is_main_query() || ! is_a( $query, 'WP_Query' ) )
    return;


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment