Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#53125 closed defect (bug) (fixed)

Logged error messages should not be translateable

Reported by: malthert's profile malthert Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Database Keywords: 2nd-opinion has-patch
Focuses: Cc:

Description

e.g. wp-db.php has an error message:

$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );

Since this is error logged, we will end up with 5 different languages of this string in error log, when using multilingual websites.
General consensus for software is that errors in logs should always be in English. (unlike errors displayed to the user).

Since %1$s and %2$s in this string are in English (since mysql always returns errors in English), we end up with a language mish-mash.

Change History (9)

#1 follow-up: @SergeyBiryukov
4 years ago

  • Component changed from General to Database
  • Keywords 2nd-opinion added

Thanks for the ticket!

General consensus for software is that errors in logs should always be in English. (unlike errors displayed to the user).

Just noting that this message can also be displayed to the user, depending on the $show_errors property value, e.g. when WP_DEBUG and WP_DEBUG_DISPLAY are both true. That said, this does appear to be the only translatable message in core that is logged regardless of the WP_DEBUG_LOG value.

I can see the point of having the message be consistently logged in English, but that would be inconsistent with pretty much any other error message in WordPress, they are generally all translated for better user experience.

#2 @malthert
4 years ago

Then perhaps we just add a condition for the case where it is logged to error log, so it will be a non-translated string in that case?

#3 @malthert
2 years ago

Well, if you are using logging (and are able to fix this DB issue), you have some IT knowledge and will be somewhat proficient in English. Thus it makes sense to have this error message in English.
Even if you are not proficient in English (and therefore no IT knowledge): this is an issue you cannot fix yourself - therefore you open a support ticket with your hoster. It's much easier for them to have error messages in English, than in 50 languages.

Even though this could theoretically be displayed to the user, this error only makes sense in English - as it's less actionable when it's translated.

This ticket was mentioned in PR #2812 on WordPress/wordpress-develop by kkmuffme.


2 years ago
#4

  • Keywords has-patch added

#5 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.1
  • Summary changed from Error messages should not be translateable to Logged error messages should not be translateable

#6 in reply to: ↑ 1 @SergeyBiryukov
2 years ago

Replying to SergeyBiryukov:

Just noting that this message can also be displayed to the user, depending on the $show_errors property value, e.g. when WP_DEBUG and WP_DEBUG_DISPLAY are both true.

It looks like this comment was not entirely correct, as the message displayed to the user here is not the same as the one that is logged.

The PR should be good to go. One minor adjustment I would make is that wp_load_translations_early() can now be called later, only if $this->show_errors is true. This can be addressed on commit.

#7 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 53505:

Database: Don't translate the "WordPress database error" message in the error log.

When using multilingual websites, this string could end up with multiple different translations in the error log, making it less actionable.

Unlike errors displayed to the user, a general consensus for software is that errors in logs should always be in English. Since MySQL errors are also returned in English, this brings more consistency to the logs.

Follow-up to [6391], [8168], [19760].

Props malthert.
Fixes #53125.

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


2 years ago

Note: See TracTickets for help on using tickets.