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.

git-svn-id: https://develop.svn.wordpress.org/trunk@36214 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-01-07 03:31:48 +00:00
parent c67abd1c66
commit 3a9bc32949
2 changed files with 22 additions and 0 deletions

View File

@@ -642,6 +642,23 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase {
}
/**
* @ticket 35321
*/
public function test_wp_insert_term_with_null_description() {
register_taxonomy( 'wptests_tax', 'post' );
$term = wp_insert_term( 'foo', 'wptests_tax', array(
'description' => null
) );
$term_object = get_term( $term['term_id'] );
$this->assertInstanceOf( 'WP_Term', $term_object );
$this->assertSame( '', $term_object->description );
}
/** Helpers **********************************************************/
public function deleted_term_cb( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) {