Make WordPress Core


Ignore:
Timestamp:
11/30/2021 09:00:32 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/sanitize-option.php

    r48937 r52294  
    156156            array( '/%year%/%monthnum%/%day%/%postname%/', '/%year%/%monthnum%/%day%/%postname%/', true ),
    157157            array( '/%year/%postname%/', '/%year/%postname%/', true ),
     158            array( new WP_Error( 'wpdb_get_table_charset_failure' ), false, false ), // ticket 53986
    158159        );
    159160    }
Note: See TracChangeset for help on using the changeset viewer.