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.
Fixes #51073.
Built from https://develop.svn.wordpress.org/trunk@48850


git-svn-id: http://core.svn.wordpress.org/trunk@48612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-08-24 10:48:06 +00:00
parent 4b28c4804d
commit 5ce95b7c88
2 changed files with 10 additions and 2 deletions

View File

@ -198,11 +198,19 @@ if ( $current_screen->is_block_editor() ) {
} }
} }
$error = error_get_last();
// Print a CSS class to make PHP errors visible. // Print a CSS class to make PHP errors visible.
if ( error_get_last() && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) { if ( $error && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
// Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
// and should not be displayed with the `error_reporting` level previously set in wp-load.php.
&& ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) )
) {
$admin_body_class .= ' php-error'; $admin_body_class .= ' php-error';
} }
unset( $error );
?> ?>
</head> </head>
<?php <?php

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-alpha-48848'; $wp_version = '5.6-alpha-48850';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.