Make WordPress Core

Changeset 48851


Ignore:
Timestamp:
08/24/2020 10:48:24 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Administration: Don't print the .php-error class in the admin header for PHP notices in wp-config.php.

Any notices in that file happen before WP_DEBUG takes effect, and should not be displayed with the error_reporting level previously set in wp-load.php.

Adding the class when there is no notice displayed results in extra padding under the admin bar, which should be avoided.

Follow-up to [20102], [21025], [26620], [47745].

Props akissz, tw2113, laxman-prajapati, sabernhardt, johnbillion, SergeyBiryukov.
Merges [48850] to the 5.5 branch.
Fixes #51073.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-admin/admin-header.php

    r48412 r48851  
    199199}
    200200
     201$error = error_get_last();
     202
    201203// Print a CSS class to make PHP errors visible.
    202 if ( error_get_last() && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) {
     204if ( $error && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
     205    // Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
     206    // and should not be displayed with the `error_reporting` level previously set in wp-load.php.
     207    && ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) )
     208) {
    203209    $admin_body_class .= ' php-error';
    204210}
     211
     212unset( $error );
    205213
    206214?>
Note: See TracChangeset for help on using the changeset viewer.