Make WordPress Core

Opened 4 weeks ago

Last modified 3 weeks ago

#64527 new defect (bug)

Fix missing whitespace before troubleshooting link in fatal error handler

Reported by: presskopp's profile Presskopp Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3
Component: Upgrade/Install Keywords: has-screenshots
Focuses: Cc:

Description

The fatal error handler concatenates the troubleshooting link directly after
the previous sentence, resulting in output like:

"... support forums.Learn more about troubleshooting WordPress."

The patch adds a whitespace before the link to ensure proper sentence
separation.

Affects: wp-includes/class-wp-fatal-error-handler.php

Attachments (3)

64527_before.png (14.5 KB) - added by Presskopp 4 weeks ago.
64527_after.png (14.8 KB) - added by Presskopp 4 weeks ago.
critical-error-page.png (112.0 KB) - added by wildworks 3 weeks ago.
What the PHP critical error page looks like when two paragraphs are combined

Download all attachments as: .zip

Change History (15)

This ticket was mentioned in PR #10752 on WordPress/wordpress-develop by @Presskopp.


4 weeks ago
#1

  • Keywords has-patch added

Adds whitespace between fatal error message and troubleshooting link. Prevents sentence concatenation like "forums.Learn more".

Trac ticket: #64527

@Presskopp
4 weeks ago

#2 @Presskopp
4 weeks ago

  • Keywords has-screenshots added

#3 @wildworks
4 weeks ago

Thanks for submitting a ticket and a patch.

However, I don't think adding whitespace between paragraphs is an ideal approach. This is because in some languages. there are no spaces between words.

Additionally, could you tell us to show the message? Do you know of any testing instruction to force that message to appear?

#4 @Presskopp
4 weeks ago

You can force the error by putting any incorrect code into the file \wp-admin\includes\class-plugin-upgrader.php before you click 'update now'

#5 @Presskopp
4 weeks ago

The issue here is that html gets stripped out, the output is plain text. Yes, my patch can't be the solution to this but it illustrates the issue.

#6 @sabernhardt
4 weeks ago

  • Component changed from General to Upgrade/Install

The updates script removes HTML from the error message, and that message is escaped later.

The escaped error message is inserted into the list table <div> created in wp_plugin_update_row().

I tried ignoring the a element, which shows the opening link tag markup but not the paragraphs.
error = error.replace( /<[\/b-z][^<>]*>/gi, '' );

Resulting HTML:
<div class="update-message notice inline notice-alt notice-error"><p>Update failed: There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the &lt;a href="https://wordpress.org/support/forums/"&gt;support forums.&lt;a href="https://wordpress.org/documentation/article/faq-troubleshooting/"&gt;Learn more about troubleshooting WordPress.</p></div>

Displays:

Update failed: There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the <a href="https://wordpress.org/support/forums/">support forums.<a href="https://wordpress.org/documentation/article/faq-troubleshooting/">Learn more about troubleshooting WordPress.


I also tried replacing tags with a space, but I am not convinced that would be a good change either.
error = error.replace( /<[\/a-z][^<>]*>/gi, ' ' );

Resulting HTML:
<div class="update-message notice inline notice-alt notice-error"><p>Update failed: There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the support forums . Learn more about troubleshooting WordPress. </p></div>

#7 @Presskopp
3 weeks ago

I initially thought this was just a missing space, but it turns out the scope is larger.
The fatal error handler appends an HTML link to the error message, while the plugin/theme update UI intentionally strips all HTML (for security reasons?).

This results in broken sentence rendering and makes it impossible for the intended “Learn more…” link to appear as an actual link in the update notice.

Patching this in updates.js does not seem like the right approach.
If we want links in update error messages, the overall error handling needs to be revisited and possibly adjusted.

Last edited 3 weeks ago by Presskopp (previous) (diff)

@wildworks commented on PR #10752:


3 weeks ago
#8

Let't close this PR as adding whitespace between paragraphs isn't an ideal approach. See https://core.trac.wordpress.org/ticket/64527#comment:3

#9 @Presskopp
3 weeks ago

  • Keywords has-patch removed

#10 @wildworks
3 weeks ago

  • Keywords has-patch added

The only solution I can think of is to combine these two paragraphs and make them translatable:

$message = '<p>' . sprintf(
        /* translators: %s: Error message. */
        __( '%s <a href="%s">Learn more about troubleshooting WordPress.</a>' ),
        $message,
        /* translators: Documentation about troubleshooting. */
        __( 'https://wordpress.org/documentation/article/faq-troubleshooting/' ),
) . '</p>';

That would at least solve the spacing issue. However, this change would also affect the layout of PHP critical error page.

@wildworks
3 weeks ago

What the PHP critical error page looks like when two paragraphs are combined

#11 @sabernhardt
3 weeks ago

  • Keywords has-patch removed
  • Version set to 5.3

The debugging/troubleshooting link was added to the message in 5.3. The sentence "Learn more about troubleshooting WordPress." is not helpful without linking it (or showing the URL). The support forums text might have some value without a link, but not as much.

5.0

Update Failed: Internal Server Error

5.2

Update Failed: The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.

5.3

Update Failed: There has been a critical error on your website. Please check your site admin email inbox for instructions.Learn more about debugging in WordPress.

6.9

Update failed: There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the support forums.Learn more about troubleshooting WordPress.

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


3 weeks ago

Note: See TracTickets for help on using tickets.