WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 8 days ago

#47321 reviewing enhancement

Show different fatal error message when in Recovery Mode and unable to redirect

Reported by: TimothyBlynJacobs Owned by: marybaum
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: has-patch servehappy has-copy-review copy-approved commit
Focuses: Cc:

Description

WP_Fatal_Error_Handler::handle() will call WP_Recovery_Mode::handle_error(). If recovery mode is active, that method will try and refresh the page via a redirect to catch multiple errors at once. However, if headers have already been sent, it bails out and returns true.

This has the effect of printing the "The site is experiencing technical difficulties. Please check your site admin email inbox for instructions." when already in Recovery Mode which may be confusing. We should display a different message when the error was handled but we were unable to redirect.

Attachments (6)

47321.diff (3.0 KB) - added by TimothyBlynJacobs 3 months ago.
47321.2.diff (3.0 KB) - added by mukesh27 3 months ago.
Updated patch.
47321.3.diff (3.0 KB) - added by garrett-eclipse 2 months ago.
Refreshed patch to include verbiage supplied by @marybaum
47321.4.diff (3.0 KB) - added by garrett-eclipse 6 weeks ago.
Updated verbiage
47321.5.diff (3.0 KB) - added by garrett-eclipse 5 weeks ago.
Updated patch
47321.6.diff (3.2 KB) - added by garrett-eclipse 2 weeks ago.
Updated patch, using 'There has been a critical error on your website.' verbiage

Download all attachments as: .zip

Change History (47)

#1 @TimothyBlynJacobs
3 months ago

I've uploaded a patch that adds the different text. The text itself is really just a placeholder and needs to be discussed.

A fatal error was caught by recovery mode. Check the Plugins and/or Themes page for details.

#2 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.2.2

This ticket was mentioned in Slack in #core-php by spacedmonkey. View the logs.


3 months ago

This ticket was mentioned in Slack in #core by sergey. View the logs.


3 months ago

@mukesh27
3 months ago

Updated patch.

#5 @mukesh27
3 months ago

@TimothyBlynJacobs patch updated as ticket address in 5.2.2 milestone and change newly added document as per core standard.

Check below:
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/author-template.php#L182
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-http.php#L156

@SergeyBiryukov Can you please check it and let me know if i am getting anything wrong.

This ticket was mentioned in Slack in #core-php by afragen. View the logs.


3 months ago

#7 @afragen
3 months ago

Adding a simple test case for triggering these errors and testing the patch would be very helpful.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


3 months ago

#9 @audrasjb
3 months ago

  • Owner set to marybaum
  • Status changed from new to reviewing

#10 follow-up: @marybaum
3 months ago

Suggested copy:

“You’re in recovery mode, but for some reason we are unable to redirect you. This may mean there are several errors. Please contact your site admin, your developer or the WordPress support forums.”

@garrett-eclipse
2 months ago

Refreshed patch to include verbiage supplied by @marybaum

#11 @marybaum
2 months ago

  • Keywords commit added

Looks good to me!

#12 in reply to: ↑ 10 @garrett-eclipse
2 months ago

  • Keywords needs-testing needs-unit-tests added; commit removed

Replying to marybaum:

Suggested copy:

“You’re in recovery mode, but for some reason we are unable to redirect you. This may mean there are several errors. Please contact your site admin, your developer or the WordPress support forums.”

I've refreshed the patch in 47321.3.diff to include @marybaum's suggested copy. Thanks @TimothyBlynJacobs & @mukesh27 for the initial patches.

Minor question: What's the policy on fancy quote in core? You’re

Also should the two other strings found in the display_default_error_template function get some copy love as well to match the tone and conveyance of this string? They are;

} elseif ( is_protected_endpoint() ) {
        $message = __( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );
} else {
        $message = __( 'The site is experiencing technical difficulties.' );
}

Also adding 'needs-unit-tests' to account for @afragen's request;
Adding a simple test case for triggering these errors and testing the patch would be very helpful.

#13 @TimothyBlynJacobs
2 months ago

“You’re in recovery mode, but for some reason we are unable to redirect you. This may mean there are several errors. Please contact your site admin, your developer or the WordPress support forums.”

I'm not sure this is 100% correct. And I think we might end up displaying a severe message too often. In technical terms, this would happen when an error happens after the page has partially rendered to the screen. I think this could end up being a large number of errors. The only thing the user needs to do in this situation is manually refresh the page or navigate to another admin page.

#14 @marybaum
2 months ago

  • Keywords needs-testing needs-unit-tests removed

“You’re in recovery mode, but for some reason we are unable to redirect you. Please try refreshing. If you see this again, please contact your site admin, your developer or the WordPress support forums.”

#15 @marybaum
2 months ago

  • Keywords commit added

#16 follow-up: @SergeyBiryukov
2 months ago

  • Keywords commit removed

Looks like this needs some more work.

we are unable to redirect you

This should be rewritten without the "we", see #46057.

Please contact your site admin, your developer

What if the user is a site admin or developer?

or the WordPress support forums

This should link to the forums.

if ( true === $handled ... )

Core does not generally use strict comparison in cases like this, if ( $handled ... ) should be enough.

#17 in reply to: ↑ 16 ; follow-up: @TimothyBlynJacobs
2 months ago

Replying to SergeyBiryukov:

if ( true === $handled ... )

Core does not generally use strict comparison in cases like this, if ( $handled ... ) should be enough.

I don't think this will work in this case since a WP_Error object will be truthy. $handled is a bool|WP_Error.

#18 in reply to: ↑ 17 @SergeyBiryukov
2 months ago

Replying to TimothyBlynJacobs:

I don't think this will work in this case since a WP_Error object will be truthy. $handled is a bool|WP_Error.

Ah, thanks, I missed that.

This ticket was mentioned in Slack in #core-php by spacedmonkey. View the logs.


2 months ago

#20 @TimothyBlynJacobs
2 months ago

  • Keywords needs-copy-review added

#21 @marybaum
2 months ago

Copy here -- how about

There's been a fatal error, so you are now in recovery mode. Please check the Plugins and/or Themes page for details.

#22 @marybaum
2 months ago

  • Keywords has-copy-review needs-refresh added

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


2 months ago

#24 @audrasjb
2 months ago

  • Milestone changed from 5.2.2 to 5.3

This ticket still needs some discussion. As seen per today's bug scrub, let's punt it to 5.3 so we could have a better resolution :-)

#25 @spacedmonkey
2 months ago

  • Component changed from Bootstrap/Load to Site Health

#26 follow-up: @garrett-eclipse
6 weeks ago

  • Keywords needs-copy-review removed

After discussing in #core-site-health here - https://wordpress.slack.com/archives/CKSU841L7/p1562699059112200

The decision was;
“There has been a critical error on your website, putting it in recovery mode. Please check the Themes and Plugins pages for more details. If you just now installed a new Theme or Plugin, check the relevant page for that first.”

@garrett-eclipse
6 weeks ago

Updated verbiage

#27 in reply to: ↑ 26 @garrett-eclipse
6 weeks ago

  • Keywords needs-copy-review dev-feedback needs-unit-tests added; has-copy-review needs-refresh removed

Replying to garrett-eclipse:

After discussing in #core-site-health here - https://wordpress.slack.com/archives/CKSU841L7/p1562699059112200

The decision was;
“There has been a critical error on your website, putting it in recovery mode. Please check the Themes and Plugins pages for more details. If you just now installed a new Theme or Plugin, check the relevant page for that first.”

I've updated the verbiage according to the Slack discussion mentioned above in 47321.4.diff.

Aside from the verbiage the outstanding questions were;
Original comment by garrett-eclipse:

Also should the two other strings found in the display_default_error_template function get some copy love as well to match the tone and conveyance of this string? They are;

} elseif ( is_protected_endpoint() ) {
        $message = __( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );
} else {
        $message = __( 'The site is experiencing technical difficulties.' );
}

Also adding 'needs-unit-tests' to account for @afragen's request;
Adding a simple test case for triggering these errors and testing the patch would be very helpful.

*Added dev-feedback, needs-copy-review and needs-unit-tests to address these items.

#28 @garrett-eclipse
6 weeks ago

P.S. Please along with the initial patch props for @TimothyBlynJacobs & @mukesh27 can you please ensure additional props for the copy discussion be added for @SergeyBiryukov (as he provided input here on Trac), @marybaum, @clorith, @afragen and @mdwolinski as they participated in the Slack copy discussion. Thank you

#29 @SergeyBiryukov
6 weeks ago

Please check the Themes and Plugins pages for more details.

I think admin pages are generally referred to as screens in documentation, to avoid confusion with page as a post type.

If you just now installed a new Theme or Plugin, check the relevant page for that first.

I don't think we generally capitalize "theme" or "plugin" in sentences like this.

Looks good to me otherwise.

@garrett-eclipse
5 weeks ago

Updated patch

#30 @garrett-eclipse
5 weeks ago

Thanks @SergeyBiryukov greatly appreciate the input

I've updated the patch (47321.5.diff) with the following;

  • Updated versions to 5.3 from 5.2.2
  • Updated 'pages' to 'screens'
  • Lowercased references to installing themes and plugins but left the screen names capitalized.
  • Updated the 'If you just now installed a theme or plugin' verbiage to cover updates by stating 'If you just installed or updated a theme or plugin'. *Also dropped 'now' as it felt redundant and in many cases they may have done an update before the weekend and only come back to work to find the issue later.

*Concerning the capitalization I went through core and from searching found that in a sentence a plugin or theme reference is lowercase such as install a plugin. But when referring to a screen it's a name and is capitalized.

Thoughts?

#31 follow-up: @garrett-eclipse
5 weeks ago

*Probably easier to review at a glance if I surfaced the full sentence, in 47321.5.diff it is as follows;
'There has been a critical error on your website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.'

#32 in reply to: ↑ 31 @marybaum
5 weeks ago

I think we have a winner!

Replying to garrett-eclipse:

*Probably easier to review at a glance if I surfaced the full sentence, in 47321.5.diff it is as follows;
'There has been a critical error on your website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.'

#33 @marybaum
5 weeks ago

  • Keywords has-copy-review copy-approved added; needs-copy-review removed

#34 follow-up: @garrett-eclipse
5 weeks ago

Awesome thanks @marybaum

So to move this forward the only outstanding questions were;

Also should the two other strings found in the display_default_error_template function get some copy love as well to match the tone and conveyance of this string? They are;
} elseif ( is_protected_endpoint() ) {

$message = ( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );

} else {

$message = ( 'The site is experiencing technical difficulties.' );

}
Also adding 'needs-unit-tests' to account for @afragen's request;
Adding a simple test case for triggering these errors and testing the patch would be very helpful.

@clorith / @afragen / @TimothyBlynJacobs do we want to make those two additional strings consistent with this new one? And does this actually need Unit Tests?
Thanks

#35 @afragen
5 weeks ago

I was only thinking of unit tests so we could be sure we know what activates this code. I’m OK with removing that tag.

#36 @garrett-eclipse
5 weeks ago

  • Keywords needs-unit-tests removed

Thanks @afragen I've dropped the tag so the only remaining question is should those two additional strings be updated to be more consistent with the new verbiage. If not this is ready to move into commit, otherwise am happy to include those strings in the patch. Cheers

#37 in reply to: ↑ 34 @marybaum
2 weeks ago

Replying to garrett-eclipse:

OMG I missed this part completely! Yes, I think we should update these two strings to match.

<?php
} elseif ( is_protected_endpoint() ) {

$message= ( 'There has been a critical error. Please check your site's admin email for instuctions.' );

} else {

$message= ( 'There has been a critical error.' );

}

Awesome thanks @marybaum

So to move this forward the only outstanding questions were;

Also should the two other strings found in the display_default_error_template function get some copy love as well to match the tone and conveyance of this string? They are;
} elseif ( is_protected_endpoint() ) {

$message = ( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );

} else {

$message = ( 'The site is experiencing technical difficulties.' );

}
Also adding 'needs-unit-tests' to account for @afragen's request;

Last edited 2 weeks ago by marybaum (previous) (diff)

@garrett-eclipse
2 weeks ago

Updated patch, using 'There has been a critical error on your website.' verbiage

#38 @garrett-eclipse
2 weeks ago

Thanks @marybaum I've refreshed the patch - 47321.6.diff

@afragen / @SergeyBiryukov could you have a last look, I feel this is ready for commit

#39 @afragen
2 weeks ago

@garrett-eclipse it looks good to me.

#40 @garrett-eclipse
2 weeks ago

  • Keywords commit added; dev-feedback removed

Thanks @afragen marking it good to go

This ticket was mentioned in Slack in #core-site-health by garrett-eclipse. View the logs.


8 days ago

Note: See TracTickets for help on using tickets.