• This php error pops up intermittently on valid URLs

    error type: [8] Undefined offset: 0 file: /home/web/wp-content/plugins/wp-super-cache/wp-cache-phase2.php line: 1217

    Don’t know why the warning is happening but this code seems to avoid the condition.

    function wp_cache_post_id() {
    	global $posts, $comment_post_ID, $post_ID;
    	// We try hard all options. More frequent first.
    	if ($post_ID > 0 ) return $post_ID;
    	if ($comment_post_ID > 0 )  return $comment_post_ID;
    
    	if ( is_single() || is_page() ) {
    		if ( isset( $posts[0] ) && is_object( $posts[0] ) ) {
    			return $posts[0]->ID;
    		}
    	}
    	if (isset( $_GET[ 'p' ] ) && $_GET['p'] > 0) return $_GET['p'];
    	if (isset( $_POST[ 'p' ] ) && $_POST['p'] > 0) return $_POST['p'];
    	return 0;
    }

    https://wordpress.org/plugins/wp-super-cache/

  • The topic ‘PHP error at line 1217 in wp-cache-pahse2.php’ is closed to new replies.