Make WordPress Core


Ignore:
Timestamp:
01/07/2016 03:31:48 AM (9 years ago)
Author:
boonebgorges
Message:

Ensure 'description' is a string in wp_insert_term().

Passing 'description' => null when creating a term can cause MySQL notices,
as the description column in the terms table does not allow for null values.
We correct this by intepreting a null description as an empty string.

Props TimothyBlynJacobs.
Fixes #35321.

File:
1 edited

Legend:

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

    r36108 r36214  
    25802580        return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
    25812581    }
     2582
    25822583    $args['name'] = $term;
    25832584    $args['taxonomy'] = $taxonomy;
     2585
     2586    // Coerce null description to strings, to avoid database errors.
     2587    $args['description'] = (string) $args['description'];
     2588
    25842589    $args = sanitize_term($args, $taxonomy, 'db');
    25852590
Note: See TracChangeset for help on using the changeset viewer.