Cannot modify header information - WSOD

197 Views Asked by At

wp-admin or dashboard wsod

Website looks fine, only dashboard wsod.

Set WP_DEBUG to true.

No errors displayed.

Then I added no-white-screen.php in mu-plugins as ref. suggested.

These are my errors:

Cannot modify header information - headers already sent by (output started at /home/content/58/11808258/html/FFG/wp-includes/pomo/mo.php:2) Backtrace from warning In /home/content/58/11808258/html/FFG/wp-includes/functions.php [line 1141]:
[line ?] calling process_error() /home/content/58/11808258/html/FFG/wp-includes/functions.php [line 1141] calling header_remove() /home/content/58/11808258/html/FFG/wp-admin/admin.php [line 33] calling nocache_headers() /home/content/58/11808258/html/FFG/wp-admin/index.php [line 10] calling require_once()

There are more similar errors but I won't add these, I don't want to spam.

I haven't added any new plugins or done any theme changes, I've anyways deactivated them (by renaming ftp folders) and the problem persisted.

This is the section of function.php that is reporting the errors:

    function nocache_headers() {
    $headers = wp_get_nocache_headers();
    unset( $headers['Last-Modified'] );
    // In PHP 5.3+, make sure we are not sending a Last-Modified header.
    if ( function_exists( 'header_remove' ) ) {
        @header_remove( 'Last-Modified' );
    } else {
        // In PHP 5.2, send an empty Last-Modified header, but only as a
        // last resort to override a header already sent. #WP23021
        foreach ( headers_list() as $header ) {
            if ( 0 === stripos( $header, 'Last-Modified' ) ) {
                $headers['Last-Modified'] = '';
                break;
            }
        }
    }
    foreach ( $headers as $name => $field_value )
        @header("{$name}: {$field_value}");
}

The 'errors' are produced by these 2 lines

@header("{$name}: {$field_value}"); 

and

@header_remove( 'Last-Modified' );

Any help greatly appreciated!

1

There are 1 best solutions below

2
On

This error suggests that some code is outputing content before the page is complete. This is often brought about by an echo throwing out text or other page components during the wrong part of the WordPress cycle (eg during a background operation / hook).

This is quite a generic error at this stage so you'll need to identify the cause of the issue via a process of elimination. You can start by doing the following:

  1. Rename your plugins folder, so as to ensure all plugins are 100% disabled. Rename wp-content/plugins to 'wp-content/plugins-x' or something similar.

If this restores admin/dashboard access, you can rename the plugin folder and then re-activate plugins one by one until the error returns. At this point, you'll know which plugin is the cause.

If that doesn't get you back into admin you may need to do a similar things with the themes folder.

  1. If that doesn't get you back into admin you may need to do a similar things with the themes folder. If renaming plugins fixes it, then you know it's a plugin causing the issue. Otherwise, it would suggest some bad code in your theme.

If renaming plugins fixes it, then you know it's a plugin causing the issue. Otherwise, it would suggest some bad code in your theme. I'd recommend checking the functions.php file first as this is where most tinkering usually takes place.

In particular, carefully examing any code you might have added or customised.

If you have access to server logs, take a look at these as they should provide more precise info as to the source or at least the point when the issue occurrs.