From 0e0c6a7ee78c892f4d63740f29c6f9e0b8034118 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 7 Jan 2016 03:32:28 +0000 Subject: [PATCH] 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 --- wp-includes/taxonomy.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 9865f42be7..78dd52ced9 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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) diff --git a/wp-includes/version.php b/wp-includes/version.php index cc0ab9dc7f..37b6a01d09 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.