Support » Plugin: Ultimate Reviews » Improper usage of output buffers

  • Resolved Nextendweb

    (@nextendweb)


    Hi,
    I’m collecting how plugins and themes use output buffers in they code to prevent future conflicts. It seems like your plugin contains an output buffering implementation which can break other plugins and themes. Here you can check my collection: https://github.com/nextend/wp-ob-plugins-themes/blob/master/README.md

    In your code: Functions/EWD_URP_Output_Buffering.php does nothing as you didn’t change anything in the output buffer. Either you should remove this file and the require of this file or you should change the file to:

    <?php
    $priority = 10;
    
    function EWD_URP_add_ob_start() {
        ob_start();
    }
    
    add_action('template_redirect', 'EWD_URP_add_ob_start', $priority);
    
    function EWD_URP_flush_ob_end() {
        ob_end_flush();
    }
    
    add_action('shutdown', 'EWD_URP_flush_ob_end', -1 * $priority);

    I checked another plugin of yours (front-end-only-users) and it has also the same thing. I haven’t checked all of your plugins, but you should do and change all of them to the suggested code.

    Also we have a tester plugin which helps you to identify wrong usage of output buffers: https://wordpress.org/plugins/output-buffer-tester/

    • This topic was modified 3 years, 8 months ago by Nextendweb.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor EtoileWebDesign

    (@etoilewebdesign)

    Hi next,

    Could you let us know how adding a blank buffer could break someone else’s plugin, considering the output should be unaffected?

    Thread Starter Nextendweb

    (@nextendweb)

    Hi @etoilewebdesign,
    Simple. You close others output buffer too early. Output buffers are stacked. So if you fail, you do not close your output buffer instead you close an output buffer of someone else and the someone else closes yours. It results unexpected problems.

    Imagine the situation of a page cache plugin. You close the output buffer of the page cache plugin in wp_footer action so the footer might be missing from the cache. ob_start( ‘page_cache’ );

    There are the references from other plugins and themes in github in my first post.

    Thread Starter Nextendweb

    (@nextendweb)

    Also in the following topic you can see several examples: https://wordpress.org/support/topic/smart-slider-3-conflict-and-code-improvement-suggestion/

    Ps.: Output buffering in your code is waste of resources, you just simple remove it from your plugins as it has no purpose.

    I wanted to add that i too had this exact issue with the smart slider 3 and it was not allowing it to load. I really want to use this plugin and we paid for the pro version so i hope you will address this so we can do updates and such. I did implement the code fix listed here and it all works perfectly now

    • This reply was modified 3 years, 8 months ago by actwd.
    Plugin Contributor EtoileWebDesign

    (@etoilewebdesign)

    We’re in the process of trying to figure out how to implement a way to use the buffer similar to the suggested method, as the buffer is needed for exporting via spreadsheet.

    Thread Starter Nextendweb

    (@nextendweb)

    @etoilewebdesign, I can help you if you describe where do you stuck. Probably we can figure out a simple solution for your issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Improper usage of output buffers’ is closed to new replies.