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.
Built from https://develop.svn.wordpress.org/trunk@36214


git-svn-id: http://core.svn.wordpress.org/trunk@36181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-01-07 03:32:28 +00:00
parent 0b9f825e29
commit 0e0c6a7ee7
2 changed files with 6 additions and 1 deletions

View File

@ -2579,8 +2579,13 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
if ( $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) {
return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
}
$args['name'] = $term;
$args['taxonomy'] = $taxonomy;
// Coerce null description to strings, to avoid database errors.
$args['description'] = (string) $args['description'];
$args = sanitize_term($args, $taxonomy, 'db');
// expected_slashed ($name)

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36205';
$wp_version = '4.5-alpha-36214';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.