WordPress.org

Ready to get started?Download WordPress

Forums

Plugin does ob_start() universally. Bad practice? (1 post)

  1. kitchin
    Member
    Posted 10 months ago #

    One of the XML sitemap plugins does this in the main plugin file, outside of any hook:

    // Pre-emptive
    $foo_ob_level = @ob_get_level();
    $foo_ob_start = ob_start();

    Seems like bad practice. Ob is always on, even on admin pages. Prevents me from flush()'ing data on long admin tasks, for one thing.

    The whole purpose is so the plugin can discard any stray output before outputting its XML sitemap. What should it be hooking on? It is already hooking the action 'parse_request' to trigger the sitemap.

    IIRC, headers_sent() should be false at 'parse_request', with or without ob. Seems like the ob is not needed at all, just set the XML headers and go. Unless they are fighting some other plugin???

    The other way to go is leave the ob_start() where it is but condition it on the right $_REQUEST vars. They've buried those names in some spaghetti code, with a filter on one of the variable names.

    Thanks....

Reply

You must log in to post.

About this Topic