WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
PHP Warning re missing array / wp-cache-phase2.php (7 posts)

  1. lwdgrfx
    Member
    Posted 2 years ago #

    Hi, Donncha - I'm trying to track down the source of this warning:

    PHP Warning: in_array() expects parameter 2 to be array, null given in (my domain) /wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line

    My error log is showing this warning every few seconds and has been for the past few days. I started looking to see what the problem might be since we had 'site unavailable' warnings for posters. The cache itself is doing an excellent job. It's a high-traffic site (for us, at least), and recently reached 80,000 posts on one day. This is a new problem, though.

    Will appreciate any help.

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. lwdgrfx
    Member
    Posted 2 years ago #

    Incidentally, where I write 'on line' above, the actual error message says 'on line 78' - which is this:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    78 and 79: if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This is the code surrounding it:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    (Line 67) if ( isset( $_GET[ 'preview' ] ) ) {
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching preview post.', 2 );
    return false;
    }

    if ( !empty( $_GET ) ) {
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request.', 5 );
    $super_cache_enabled = false;
    }

    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
    return false;
    }
    if (wp_cache_user_agent_is_rejected()) {
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
    return;
    }
    if($wp_cache_gzip_encoding)
    header('Vary: Accept-Encoding, Cookie');
    else
    header('Vary: Cookie');
    ob_start( 'wp_cache_ob_callback' );
    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Created output buffer', 4 );

    // restore old supercache file temporarily
    ~~~~~~~~~~~~~~~~~~~~~~~~~~`

  3. lwdgrfx
    Member
    Posted 2 years ago #

    Does anyone else have any idea what is causing this PHP error? If I can't find it, I'm going to have to uninstall Super Cache.

  4. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Did you check the contents of the second parameter, it should be this (taken from the config file wp-content/wp-cache-config.php)

    $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );

  5. lwdgrfx
    Member
    Posted 2 years ago #

    Thanks, Donncha. I was thinking the other day it would be great to see all my Super Cache settings on one page instead of going through the tabs one by one. I had never looked at 'wp-content/wp-cache-config.php' before but there they are and that will be a great place to keep track of what's set how.

    Since I didn't know what was causing the error, I actually deactivated SuperCache on Thursday and was wondering what to do when we received a comment on Friday from someone saying she could not find any posts from Thursday. I decided to reactivate it, changed a few settings (which I'm now going to review to see what's different plus compare to the 'wp-content/wp-cache-config.php' file and do screenshots of settings since the configuration is now working correctly and I'm getting no PHP errors at all.

    This 'wp-content/wp-cache-config.php' file did, in fact (after the re-activation) show this:
    =============================
    $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
    =============================
    so that seems to have been the problem causing the error warning. What I don't know is what setting would have changed that but, as I say, I'm now planning to review them all.

    I'm waiting for my posters to tell me if their posting is going better now or if the 'site unavailable' message was caused by something else. When I mentioned the 'site unavailable' messages to my hosting support, he pointed me to the php errors log where the error I mention above was the only one it showed.

  6. lwdgrfx
    Member
    Posted 2 years ago #

    Oh...I spoke too soon...

    We just had several instances of 'site unavailable' happen and I now have PHP errors again. They're not the same as those I had earlier this week but they're similar. Here they are:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [03-Aug-2012 16:49:09] PHP Warning: in_array() [function.in-array]: Wrong datatype for second argument in (my domain)/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 78
    [07-Aug-2012 11:07:02] PHP Warning: in_array() [function.in-array]: Wrong datatype for second argument in (my domain)/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 78
    =============================================================
    The 'wp-content/wp-cache-config.php' file however, shows this:

    =============================
    $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
    ================================================
    Any further thoughts on what the problem might be?

  7. Donncha O Caoimh
    Member
    Plugin Author

    Posted 1 year ago #

    Still having problems? Did your host update PHP or install a PHP optimizer perhaps?

    Otherwise dump $cache_acceptable_files to a file just before it's supposed to be used, or even define it just before line 78. There's something weird happening on your server :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic