WordPress.org

Make WordPress Core

Ticket #20850: 20850.patch

File 20850.patch, 1.1 KB (added by kurtpayne, 6 years ago)

Check the term name, not slug, use LIKE BINARY

  • wp-includes/taxonomy.php

     
    14791479        if ( '' === $slug = sanitize_title($term) )
    14801480                return 0;
    14811481
    1482         $where = 't.slug = %s';
    1483         $else_where = 't.name = %s';
    1484         $where_fields = array($slug);
    1485         $else_where_fields = array($term);
     1482        $where = 't.name LIKE BINARY %s';
     1483        $else_where = 't.slug = %s';
     1484        $where_fields = array($term);
     1485        $else_where_fields = array($slug);
    14861486        if ( !empty($taxonomy) ) {
    14871487                $parent = (int) $parent;
    14881488                if ( $parent > 0 ) {
     
    20562056                }
    20572057        }
    20582058
    2059         if ( $term_id = term_exists($slug) ) {
     2059        if ( $term_id = term_exists($name) ) {
    20602060                $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
    20612061                // We've got an existing term in the same taxonomy, which matches the name of the new term:
    20622062                if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) {