From 770a909a5f8ec2863b85a572496db752ca0f452a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 15 Jun 2022 10:34:07 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53505 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 4b0b975b32..44a4434319 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -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(