diff --git a/wp-includes/version.php b/wp-includes/version.php index 2b5001dfdd..ead1098ee5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52175'; +$wp_version = '5.9-alpha-52176'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 53ba207203..57c3bd76f6 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -2015,7 +2015,15 @@ class wpdb { // to flush again, just to make sure everything is clear. $this->flush(); if ( $stripped_query !== $query ) { - $this->insert_id = 0; + $this->insert_id = 0; + $this->last_query = $query; + + if ( function_exists( '__' ) ) { + $this->last_error = __( 'WordPress database error: Could not perform query because it contains invalid data.' ); + } else { + $this->last_error = 'WordPress database error: Could not perform query because it contains invalid data.'; + } + return false; } } @@ -2535,6 +2543,32 @@ class wpdb { $converted_data = $this->strip_invalid_text( $data ); if ( $data !== $converted_data ) { + + $problem_fields = array(); + foreach ( $data as $field => $value ) { + if ( $value !== $converted_data[ $field ] ) { + $problem_fields[] = $field; + } + } + + if ( 1 === count( $problem_fields ) ) { + if ( function_exists( '__' ) ) { + /* translators: %s Database field where the error occurred. */ + $message = __( 'WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.' ); + } else { + $message = 'WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.'; + } + } else { + if ( function_exists( '__' ) ) { + /* translators: %s Database fields where the error occurred. */ + $message = __( 'WordPress database error: Processing the value for the following fields failed: %s. The supplied value may be too long or contains invalid data.' ); + } else { + $message = 'WordPress database error: Processing the value for the following fields failed: %s. The supplied value may be too long or contains invalid data.'; + } + } + + $this->last_error = sprintf( $message, implode( ', ', $problem_fields ) ); + return false; }