Support » Plugin: WP Cerber Security, Anti-spam & Malware Scan » headers already sent

  • Resolved glouton

    (@glouton)


    Hi there,

    Just installed Wp Cerber and got this error repeatedly in log (really a lot) :

    PHP Warning: Cannot modify header information – headers already sent in /wp-content/plugins/wp-cerber/common.php on line 2492

    I’ve had this with multiple other plugins and it was due to the way WordPress deals with php 7.0.16+ in wp-cron.php on lines 22 to 24.

    Maybe you’re dealing with the same issue.

    Regards,

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Gregory

    (@gioni)

    Hi! If you come across an issue with WP Cerber, you can find the answer on wpcerber.com: https://wpcerber.com/php-warning-cannot-modify-header-information/

    Thread Starter glouton

    (@glouton)

    Hello,

    Thank you for answering but I really think you’re wrong.

    I’ve had this with other plugins, explaining the authors i’ve checked and clean all the code, tested one clean WordPress install… etc..

    One has fixed his own code, CPB Poll:
    https://wordpress.org/support/topic/headers-already-sent-39/

    One kept pretending “it’s not us, it’s someone else”, Contact Form 7 Multi-Step Forms:
    https://wordpress.org/support/topic/hea/

    Former fixed the issue, later did nothing and message in log did indeed vanish after removing this extension.

    I know what can cause header already sent warning. But then again, didn’t have it before installing WP Cerber.

    And as I pointed here and for the other plugin authors, it’s because wp-cron.php calls fastcgi_finish_request() if you run PHP 7.0.16 >=, which sends headers.

    But that’s a WordPress core file. So it depends if you want you plugin to be compatible with WordPress and PHP >= 7 or not.

    Regards,

    Thread Starter glouton

    (@glouton)

    PS:

    I’ve installed WP Cerber locally and on test environment and have the warning on both.

    I haven’t deployed it to production yet, where I don’t have the warning.

    Plugin Author Gregory

    (@gioni)

    I’ve had this with multiple other plugins and it was due to the way WordPress deals with php 7.0.16+ in wp-cron.php on lines 22 to 24.

    If so, probably something is wrong with your server configuration. What’s the server stack and modules do you run?

    But that’s a WordPress core file. So it depends if you want you plugin to be compatible with WordPress and PHP >= 7 or not.

    The plugin works just fine on PHP 7.X except your case. Perhaps someone else came across the same issue but nobody has reported yet.

    Thread Starter glouton

    (@glouton)

    Hello,

    That’s really weird!
    I launched the same test I ran for the others.

    • Start with a fresh install of WordPress 5.3
    • Install and activate WP Cerber
    • Install and activate my single file dummy cron plugin below

    See the result in the the attached log, tones of “headers already sent” after installing your plugin and then 4 every minute because of the cron.

    After the WordPress install I’ve check cron in the database, table wp_options with option_name = ‘cron’.
    There was only core tasks.
    Then I activated WP Cerber and had 2 warnings in log right after activation + WP Cerber cron tasks added on database.
    Then I activated my dummy cron which added to more warnings in log.

    >> The plugin works just fine on PHP 7.X except your case. Perhaps someone else came across the same issue but nobody has reported yet.

    I might be wrong but it really look like the plugin raises this warning when WordPress cron task runs. Which is a core functionnality.

    I running PHP 7.3.11 with Apache 2.4.6 and PHP-FPM under Centos 7.7

    PHP-FPM log file: https://mega.nz/#!YjYzwS5R!o-twJ8Wh6lUnIQv-wZnJJ1JBnn7UWiNw5S4kxKfVwzg
    WordPress Extensions: https://mega.nz/#!56BXDAZY!uKlJ7yEaARcG3u-hknMZm7Lgu3N2JkvpiO_jvug0dTM

    • This reply was modified 2 years, 8 months ago by glouton.
    Thread Starter glouton

    (@glouton)

    Sorry, forgot the dummy-cron.php

    <?php
    /**
     * Plugin Name: Dummy Cron
     */
    function my_add_minutely( $schedules ) {
        // add a 'minutely' schedule to the existing set
        $schedules['minutely'] = array(
            'interval' => 60,
            'display' => __('Once Minutely')
        );
        return $schedules;
    }
    add_filter( 'cron_schedules', 'my_add_minutely' );
    
    register_activation_hook(__FILE__, 'my_activation');
    
    function my_activation() {
        if (! wp_next_scheduled ( 'my_minutely_event' )) {
            wp_schedule_event(time(), 'minutely', 'my_minutely_event');
        }
    }
    
    add_action('my_minutely_event', 'do_this_minutely');
    
    function do_this_minutely() {
        // do something every minute
        error_log( 'My minutely event.' );
    }
    
    register_deactivation_hook(__FILE__, 'my_deactivation');
    
    function my_deactivation() {
        wp_clear_scheduled_hook('my_minutely_event');
    }
    Plugin Author Gregory

    (@gioni)

    Thanks for the detailed info. I’ll look into it today.

    Plugin Author Gregory

    (@gioni)

    While the next version of Cerber is in the works and will be ready in a week or so, I recommend testing the development version, the error will go away since this version has a fix: http://my.wpcerber.com/downloads/wp-cerber.8.5.4.zip

    Thread Starter glouton

    (@glouton)

    So there was something.

    Thanks for the fix, I’ll test it asap.

    Thread Starter glouton

    (@glouton)

    Hi there,

    On the same clean WordPress with my dummy Minutely event plugin, I’ve removed the previous WP Cerber and installed this 8.5.4 one.

    No more “header already sent” in log indeed.

    Thanks for fix.

    Plugin Author Gregory

    (@gioni)

    I found this improvement will be useful for someone having a server configuration similar to your. I never miss the opportunity to improve the plugin. You can add your review if you feel the plugin worth it: https://wordpress.org/support/plugin/wp-cerber/reviews/#new-post

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘headers already sent’ is closed to new replies.