Options, Meta APIs: Improve error handling in sanitize_option().
To prevent potential false negatives, set `$error` to `null` initially, so we can better tell if it was ever changed during the sanitization and be able to better react if an empty string is added to it. Additionally, and mainly for the sake of the Settings API at this point, add error messages to some `WP_Error` objects returned from `wpdb` methods that were previously causing the issues here. Follow-up to [32791]. Props iCaleb, audrasjb, hellofromTonya, SergeyBiryukov. Fixes #53986. Built from https://develop.svn.wordpress.org/trunk@52294 git-svn-id: http://core.svn.wordpress.org/trunk@51886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -2885,7 +2885,7 @@ class wpdb {
|
||||
$table = '`' . implode( '`.`', $table_parts ) . '`';
|
||||
$results = $this->get_results( "SHOW FULL COLUMNS FROM $table" );
|
||||
if ( ! $results ) {
|
||||
return new WP_Error( 'wpdb_get_table_charset_failure' );
|
||||
return new WP_Error( 'wpdb_get_table_charset_failure', __( 'Could not retrieve table charset.' ) );
|
||||
}
|
||||
|
||||
foreach ( $results as $column ) {
|
||||
@@ -3327,7 +3327,7 @@ class wpdb {
|
||||
$this->check_current_query = false;
|
||||
$row = $this->get_row( 'SELECT ' . implode( ', ', $sql ), ARRAY_A );
|
||||
if ( ! $row ) {
|
||||
return new WP_Error( 'wpdb_strip_invalid_text_failure' );
|
||||
return new WP_Error( 'wpdb_strip_invalid_text_failure', __( 'Could not strip invalid text.' ) );
|
||||
}
|
||||
|
||||
foreach ( array_keys( $data ) as $column ) {
|
||||
|
||||
Reference in New Issue
Block a user