term_exists returns (string) based $term_id value as opposed to (int).

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

term_exists returns (string) based $term_id value as opposed to (int).

Haluk Karamete
I spotted this bug while I was migrating a legacy site into WordPress

In the wp_insert_term function, there is a section that goes like this;

    if ( $term_id = term_exists($slug) ) {

        // if you are here, then you got a string based $term_id in your
        // example: (string

    } else {

        //do stuff here

        $term_id = (int) $wpdb->insert_id;

        // here, there are no problems here... cause $term_id is forced to
be an integer!

    } endif;

    Having a string term_id causes a problem later on down the road,

    When the wp_set_post_terms() is called with its $tags argument having
string formatted term_ids, those terms are considered as no-show under the
corresponding taxonomy, and wordpress creates new terms on the fly.
wp-hackers mailing list
[hidden email]