Repository navigation
Conversation
Non-ASCII slugs are stored percent-encoded, so also match the encoded form of the search string against the term slug. See #43626.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Test ReportEnvironment: wordpress-develop Docker, PHP 8.3.35, trunk 9fe0c05 + this PR (merges cleanly). Categories whose slug differs from the name, so only the slug can match. Tested with
Uppercase non-Latin searches: $slug_search = utf8_uri_encode( mb_strtolower( $search, 'UTF-8' ) );With it, Tests: |
Trac ticket: https://core.trac.wordpress.org/ticket/43626
What is wrong
Slugs that contain non-ASCII characters (for example Arabic) are stored percent-encoded in
wp_terms.slug.WP_Term_Query::get_search_sql()matched the raw search string againstt.slug, so searching for the slug of an Arabic term returned nothing, while the same search for an English slug works.What this changes
When the search string contains non-ASCII characters,
get_search_sql()also matches the encoded form of the search string (utf8_uri_encode(), lowercased) againstt.slug. For ASCII-only searches the generated SQL is unchanged.A PHPUnit test is added to
Tests_Term_getTerms:test_get_terms_search_matches_non_ascii_slug.How it was verified
Checked in WordPress Playground (PHP 8.3, SQLite) with a tag named
تاج1and slugسلج1:سلج1returned no terms.سلج1returns the tag. Searches forslug1,تاج1andcaféreturn the same results as before.The PHPUnit test is included but I could not run it locally (no MySQL), so CI here is its first real run.
Related
Open PRs #14187 (ticket 66279) and #14138 (ticket 66281) also change
get_search_sql(), so this may need a rebase if either lands first.