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


git-svn-id: http://core.svn.wordpress.org/trunk@53094 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-06-15 10:36:09 +00:00
parent 991acc48d4
commit ab5cc35046
2 changed files with 6 additions and 7 deletions

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53504';
$wp_version = '6.1-alpha-53505';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -1568,15 +1568,12 @@ class wpdb {
return false;
}
wp_load_translations_early();
$caller = $this->get_caller();
if ( $caller ) {
/* translators: 1: Database error message, 2: SQL query, 3: Name of the calling function. */
$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
// Not translated, as this will only appear in the error log.
$error_str = sprintf( 'WordPress database error %1$s for query %2$s made by %3$s', $str, $this->last_query, $caller );
} else {
/* translators: 1: Database error message, 2: SQL query. */
$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
$error_str = sprintf( 'WordPress database error %1$s for query %2$s', $str, $this->last_query );
}
error_log( $error_str );
@ -1586,6 +1583,8 @@ class wpdb {
return false;
}
wp_load_translations_early();
// If there is an error then take note of it.
if ( is_multisite() ) {
$msg = sprintf(