WordPress.org

Make WordPress Core

Changeset 34628


Ignore:
Timestamp:
09/27/2015 04:31:47 PM (5 years ago)
Author:
boonebgorges
Message:

Add test for get_term_by( 'slug' ) behavior with accented chars.

When passing a value of 'slug' to wp_insert_term() that contains non-ASCII
characters, WordPress converts accented characters to non-accented versions.
(See sanitize_title() and remove_accents().) The same conversion happens
when fetching when fetching a term using a slug. In this way, it's possible to
create a term and fetch it using the same accented string, even though the slug
is actually stored with non-accented characters.

See #16282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTermBy.php

    r34627 r34628  
    2121        $this->assertFalse( $term );
    2222    }
     23
     24    /**
     25     * @ticket 16282
     26     */
     27    public function test_get_term_by_slug_should_match_nonaccented_equivalents() {
     28        register_taxonomy( 'wptests_tax', 'post' );
     29
     30        $slug = 'ńaș';
     31        $t = $this->factory->term->create( array(
     32            'slug' => $slug,
     33            'taxonomy' => 'wptests_tax',
     34        ) );
     35
     36        $found = get_term_by( 'slug', 'nas', 'wptests_tax' );
     37        $this->assertSame( $t, $found->term_id );
     38    }
    2339}
Note: See TracChangeset for help on using the changeset viewer.