Make WordPress Core


Ignore:
Timestamp:
11/19/2021 06:58:14 PM (3 years ago)
Author:
hellofromTonya
Message:

WPDB: Call wp_load_translations_early() in wpdb::query() and wpdb::process_fields().

For consistency and simplification, replaces the function_exists( '__' ) checks with wp_load_translations_early() to make sure i18n functions are available. This change removes the extra code introduced in [52176] for using non-translated error messages when __() is not available.

Improves the plural versions of the error messages.

For performance, when there are more than one problem field, uses reset() to populate the field in the error message.

Follow-up to [52176], [52195].

Props sergeybiryukov, hellofromTonya.
Fixes #32315.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db.php

    r52176 r52218  
    11901190     */
    11911191    private function get_db_error_value_too_long( $errored_fields ) {
     1192        if ( str_contains( $errored_fields, ', ' ) ) {
     1193            return sprintf(
     1194                'WordPress database error: Processing the values for the following fields failed: %s. ' .
     1195                'The supplied values may be too long or contain invalid data.',
     1196                $errored_fields
     1197            );
     1198        }
    11921199        return sprintf(
    1193             'WordPress database error: Processing the value for the following field%s failed: %s. ' .
     1200            'WordPress database error: Processing the value for the following field failed: %s. ' .
    11941201            'The supplied value may be too long or contains invalid data.',
    1195             str_contains( $errored_fields, ', ' ) ? 's' : '',
    11961202            $errored_fields
    11971203        );
Note: See TracChangeset for help on using the changeset viewer.