[wp-trac] Re: [WordPress Trac] #6313: When you have a custom tag slug, it will duplicate tags

WordPress Trac wp-trac at lists.automattic.com
Fri Mar 28 15:27:33 GMT 2008


#6313: When you have a custom tag slug, it will duplicate tags
---------------------+------------------------------------------------------
 Reporter:  tai      |        Owner:  anonymous
     Type:  defect   |       Status:  new      
 Priority:  normal   |    Milestone:  2.6      
Component:  General  |      Version:  2.5      
 Severity:  normal   |   Resolution:           
 Keywords:           |  
---------------------+------------------------------------------------------
Comment (by lilyfan):

 I think the root cause is that is_term() (at wp-includes/taxonomy.php:
 line around 746) only sees tag slug.

 Original Code:
 {{{
 if ( '' === $term = sanitize_title($term) )
         return 0;
 $where = $wpdb->prepare( "t.slug = %s", $term );
 }}}

 if is_term() recognize tag name as below, this issue will be resolved.

 Patch:
 {{{
 if ( '' === $sanitized = sanitize_title($term) )
         return 0;
 if ( $taxonomy = 'post_tag' ) {
         $where = $wpdb->prepare( "(t.slug = %s OR t.name = %s)",
 $sanitized , $term );
 } else {
         $where = $wpdb->prepare( "t.slug = %s", $sanitized );
 }
 }}}

 ex)[[BR]]
 1) Make a tag name "abcde" with slug "aaa".[[BR]]
 2) Write a post, and add "abcde" tag[[BR]]
 3) is_term() wil pickup "abcde" tag!!

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6313#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list