Skip to content

Use locale-aware collation for attendee list sorting#1663

Open
dd32 wants to merge 2 commits intoproductionfrom
fix/claude/1310-locale-aware-attendee-sorting-v2
Open

Use locale-aware collation for attendee list sorting#1663
dd32 wants to merge 2 commits intoproductionfrom
fix/claude/1310-locale-aware-attendee-sorting-v2

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented Mar 24, 2026

Summary

  • Adds utf8mb4_unicode_520_ci collation to the ORDER BY clause when the [camptix_attendees] shortcode sorts by title
  • The default utf8mb4_unicode_ci collation uses Unicode 4.0 sorting rules, which incorrectly sorts characters like Polish Ł (after Z instead of with L)
  • Uses posts_orderby filter with suppress_filters => false as discussed in the issue comments by @dd32 and @pkevan

Changes

  • camptix/addons/shortcodes.php: Added suppress_filters => false to get_posts() args, and a temporary posts_orderby filter that adds the COLLATE clause when sorting by title

Implementation details

  • The filter is added just before the query and removed immediately after, so it only affects this specific query
  • The collation override only applies when orderby is title (the default)
  • Per @dd32: SELECT post_title FROM wc_posts WHERE post_type = 'tix_attendee' ORDER BY post_title COLLATE 'utf8mb4_unicode_520_ci' ASC produces correct sorting

Test plan

  • Existing CampTix tests pass (63 tests, 80 assertions)
  • Verify Polish characters (Ł, Ś, Ź, etc.) sort correctly on a site with Polish attendee names
  • Verify sorting still works correctly for ASCII-only attendee names

Fixes #1310

🤖 Generated with Claude Code

dd32 and others added 2 commits March 24, 2026 11:36
The camptix_attendees shortcode sorts by post_title using the default
database collation (utf8mb4_unicode_ci), which uses older Unicode 4.0
sorting rules. This causes characters like Polish Ł to sort incorrectly,
appearing after Z instead of with L.

Add a posts_orderby filter to use utf8mb4_unicode_520_ci collation when
sorting by title, and set suppress_filters to false so the filter runs.

Fixes #1310

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore locale when sorting for shortcode "camptix_attendees"

1 participant