Make WordPress Core


Ignore:
Timestamp:
01/07/2016 03:31:48 AM (10 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/tests/phpunit/tests/term/wpInsertTerm.php

    r36080 r36214  
    643643    }
    644644
     645    /**
     646     * @ticket 35321
     647     */
     648    public function test_wp_insert_term_with_null_description() {
     649
     650        register_taxonomy( 'wptests_tax', 'post' );
     651
     652        $term = wp_insert_term( 'foo', 'wptests_tax', array(
     653            'description' => null
     654        ) );
     655
     656        $term_object = get_term( $term['term_id'] );
     657
     658        $this->assertInstanceOf( 'WP_Term', $term_object );
     659        $this->assertSame( '', $term_object->description );
     660    }
     661
    645662    /** Helpers **********************************************************/
    646663
Note: See TracChangeset for help on using the changeset viewer.