Support » Plugin: WP Super Cache » wp-super-cache output buffer error and 'ob_start()

  • I am receiving this error on the txt debag file –
    “Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text ‘ob_start’ in the files of your plugins directory.”

    I don’t use any other plugin but wp-super-cache plugin.
    However, in my theme function.php there are two functions that create output buffer.
    These two functions correctly use ‘ob_start()’ and end the buffer by sending the data to output with ob_end_clean();.
    There are no other instances in the site’s theme of using output buffer.
    How do I work around this issue?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Donncha O Caoimh

    (@donncha)

    Check that the theme is correctly using ob_end_clean(), maybe use error_log to log to your server or wp_mail() to debug it. Maybe it’s calling it one too many times.

    My Apache error log is always empty. I check it periodically.
    I have just checked it again to see if any error occurred.
    No. There’s nothing in it.

    The second line of the txt debag file after the – ” Output buffer may have been corrupted…” is “No closing html tag. Not caching.”

    > Maybe it’s calling it too many times.

    Do you mean calling a buffer too many times. Could be? Here is the code of the two functions in functions.php


    <?php
    function catch_that_image() {
    global $post, $posts;
    $first_img = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $first_img = $matches [1] [0];

    if(empty($first_img)){ //Defines a default image
    $first_img = "http://localhost/wordpress/images/nissim.jpg";
    }
    return $first_img;
    }
    ?>
    <?php
    add_filter('widget_text','execute_php',100);
    function execute_php($html){
    if(strpos($html,"<"."?php")!==false){
    ob_start();
    eval("?".">".$html);
    $html=ob_get_contents();
    ob_end_clean();
    }
    return $html;
    }
    ?>

    Any clue?

    OK.
    I may have a solution. Not sure yet.
    From what I read about PHP output buffering, ob_end_clean() destroys/turns-off output buffering.
    So, it might cause an issue with super-cache plugin seeing a blank buffer when calling it.

    Therefor, I went the following way on my local server, I’ve –
    1. Deleted from the first function the ob_start() ob_end_clean() which doesn’t seem to do anything.
    2. Changed at the second function ob_end_clean(); to ob_clean();

    It seems that the two functions work fine that way, but I still haven’t seen how super-cache behaves and if it can read the buffer.
    Will post soon as I get results.

    Well, it works but I will have to check it again later.
    On the debag, I don’t see more messages about an empty buffer:
    “Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text ‘ob_start’ in the files of your plugins directory.”

    Hello Donncha,
    Unfortunately, I am still seeing “buffer is blank” on the wp-super-cache debager.

    Maybe this issue is related to the settings of the php.ini?
    I am on Linux shared server :
    * Output buffering is set to “Off”
    * zlib output compression is set to “Off”

    Please advise on the correct settings,
    Thanks
    Ziv

    Problem solved Donncha,
    With the help of BIRA (you know her) I’ve delete the second function and put the codes on the sidebar.php .
    BTW, this is the correct setting in php.ini :
    * Output buffering is set to “Off”
    * zlib output compression is set to “Off”

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp-super-cache output buffer error and 'ob_start()’ is closed to new replies.