mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-12 14:30:09 +00:00
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:
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user