WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 6 months ago

#35155 closed defect (bug) (fixed)

Error messages still get covered over by wp admin menu.

Reported by: EmpireOfLight Owned by: audrasjb
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.4
Component: Administration Keywords: has-patch has-screenshots
Focuses: ui, administration Cc:

Description

This is a follow-up to #26312. See attached.

Attachments (7)

Screen Shot 2015-12-18 at 9.46.50 AM.png (63.2 KB) - added by EmpireOfLight 5 years ago.
Shows errors covered by menu. When wp_debug is set to true in wp-config.php
35155.patch (971 bytes) - added by afercia 5 years ago.
php-error-in-wp.php (1.0 KB) - added by Mte90 5 years ago.
Plugin to wrap php errors
errors.png (13.9 KB) - added by Mte90 5 years ago.
Screenshot plugin to wrap php errors
35155.1.diff (874 bytes) - added by audrasjb 6 months ago.
Administration: Print a CSS class to make PHP errors visible in WP-Admin
Capture d’écran 2020-04-18 à 00.36.47.png (114.5 KB) - added by audrasjb 6 months ago.
35155.2.diff (937 bytes) - added by audrasjb 6 months ago.
Administration: Print a CSS class when display_errors is enabled to make PHP errors visible in WP-Admin

Download all attachments as: .zip

Change History (21)

@EmpireOfLight
5 years ago

Shows errors covered by menu. When wp_debug is set to true in wp-config.php

#1 @afercia
5 years ago

Related: #28376 and #24545.

#2 @ericlewis
5 years ago

PHP error messages can output before the wp-admin application drops an <html> tag, what can we do here?

#3 @dd32
5 years ago

For a long time I had some CSS in a mu-plugin which shifted xDebug styled errors into the visible display area, but it'd still render the admin menu hidden.

I'm curious if a JS solution could be used to detect the broken view, and add the correct top-offsets to make it mostly appear below the PHP error output..

#4 @afercia
5 years ago

Would using error_get_last() be safe? Then it would be as simple as printing out a body CSS class and use some styling:

if ( error_get_last() ) {
	$admin_body_class .= ' php-error';
}

@afercia
5 years ago

#5 @afercia
5 years ago

  • Component changed from Customize to Administration
  • Focuses ui added
  • Keywords has-patch has-screenshots added

A very basic first pass, for testing purposes. I think it's not possible to style the error messages but adding a CSS class in the body would allow to at least make the errors visible and not hidden by the menu.

https://cldup.com/LCJVz8CCRy.png

@Mte90
5 years ago

Plugin to wrap php errors

@Mte90
5 years ago

Screenshot plugin to wrap php errors

#6 @Mte90
5 years ago

  • Keywords dev-feedback added

The plugin is an example how to use the set_error_handler, that plugin add a wrapper in case if the error is showed in the admin backend.
In that case add the message error class to the wrapper with that have the same styles of the error in WordPress.
The plugin also include 2 fake error for testing.

I think that we can convert that as a patch but I don't think that is complete and I have no idea what is the ideal file.

Maybe I can create a plugin for the Wordpress repo.

#7 @Mte90
5 years ago

I uploaded that plugin on gist to manage as a real plugin https://gist.github.com/Mte90/c869ed85661d65b8c1b0

#8 @valentinbora
9 months ago

  • Focuses administration added
  • Milestone set to 5.5

@audrasjb
6 months ago

Administration: Print a CSS class to make PHP errors visible in WP-Admin

#9 @audrasjb
6 months ago

  • Keywords dev-feedback removed
  • Owner set to audrasjb
  • Status changed from new to accepted

Hi,

I'd prefer the body class approach as we don't absolutely need to have design on those error/warning notices. We just want to make them visible.

35155.1.diff refreshes the old patch and uses em margin. See screenshot above.

Should be safe to go in WP 5.5. Any thought on this @SergeyBiryukov?

Cheers,
Jb

#10 @johnbillion
6 months ago

I like this. Simple but effective.

What does this behaviour look like when there's an error but display_errors is false?

@audrasjb
6 months ago

Administration: Print a CSS class when display_errors is enabled to make PHP errors visible in WP-Admin

#11 @audrasjb
6 months ago

Ho good point @johnbillion, I didn't noticed the class will apply even when display_error is false.
Fixed in 35155.2.diff. Works fine on my side.
What is your opinion about the conditional statement I used?

#12 @audrasjb
6 months ago

Please note that this patch will probably also fix #24545.

#13 @johnbillion
6 months ago

#24545 was marked as a duplicate.

#14 @johnbillion
6 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 47745:

Administration: Reduce the chance that a PHP error message that occurs before the admin menu gets output is covered by the admin menu.

Props EmpireOfLight, afercia, Mte90, audrasjb, sunnyratilal

Fixes #35155

Note: See TracTickets for help on using tickets.