Make WordPress Core


Ignore:
Timestamp:
02/07/2019 11:34:22 PM (6 years ago)
Author:
pento
Message:

Formatting: Loosen the type checking in _sanitize_text_fields().

[44618] added strict type checking to _sanitize_text_fields(), which has caused some compat issues with plugins.

We can loosen the type checking to only reject objects and arrays, and cast other types to string.

Props Nick_theGeek, pento.
Fixes #41450.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r44714 r44731  
    51545154 */
    51555155function _sanitize_text_fields( $str, $keep_newlines = false ) {
    5156     if ( ! is_string( $str ) ) {
     5156    if ( is_object( $str ) || is_array( $str ) ) {
    51575157        return '';
    51585158    }
     5159
     5160    $str = (string) $str;
    51595161
    51605162    $filtered = wp_check_invalid_utf8( $str );
Note: See TracChangeset for help on using the changeset viewer.