fix: change slug column collation to utf8mb4_bin to fix accent-sensitive uniqueness#391
Open
ahuininga-orisha wants to merge 4 commits into
Open
fix: change slug column collation to utf8mb4_bin to fix accent-sensitive uniqueness#391ahuininga-orisha wants to merge 4 commits into
ahuininga-orisha wants to merge 4 commits into
Conversation
added 4 commits
May 27, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the PathSlugStrategy is active, filter option labels are transliterated to ASCII slugs and stored in the database. The unique index on the slug column used an accent-insensitive collation, meaning the database treated
e,é, andèas identical. Two filter values from different languages that happen to produce the same ASCII slug would silently collide, causing the wrong filter to be applied to the wrong products.The fix changes the slug column to a binary collation (
utf8mb4_bin), making the unique index accent- and case-sensitive. This collation is compatible with both MySQL 8 and MariaDB. Since slugs are always lowercased ASCII after transliteration, binary comparison is safe. A second patch cleans up duplicate legacy indexes left behind by an earlier migration.Run
bin/magento setup:upgradeafter installing.Changes
Setup/Patch/Schema/CleanupLegacyIndexesTweakwiseAttributeSlugTable.phpATTRIBUTEandSTORE_SLUGindexes that duplicated the canonical Magento-named indexes left behind byChangePrimaryKeyTweakwiseAttributeSlugTableSetup/Patch/Schema/SetSlugColumnCollationTweakwiseAttributeSlugTable.phpslugcolumn toCHARACTER SET utf8mb4 COLLATE utf8mb4_binso accent-distinct slugs are treated as unique by the database indexHow to test
Scenario 1 — Legacy indexes are removed
tweakwise_attribute_slugtable, runbin/magento setup:upgrade.SHOW INDEX FROM tweakwise_attribute_slug;in MySQL.ATTRIBUTEandSTORE_SLUGno longer exist.TWEAKWISE_ATTRIBUTE_SLUG_ATTRIBUTE_STORE_IDandTWEAKWISE_ATTRIBUTE_SLUG_STORE_ID_SLUGare present.Scenario 2 — Slug column uses utf8mb4_bin collation
SHOW CREATE TABLE tweakwise_attribute_slug;.slugcolumn showsCHARACTER SET utf8mb4 COLLATE utf8mb4_bin.Scenario 3 — Accent-distinct slugs no longer collide
store_id = 1, slugseandërespectively intotweakwise_attribute_slug.Scenario 4 — PathSlugStrategy filter URLs still resolve correctly
Röd,crème).rod,creme).