Repository navigation
[6.x] Fix duplicate localizations - #15732
Conversation
|
Thanks for this! One gap: the existence check only matches entries whose Could you look the existing localization up through the whole origin chain instead, e.g. |
@duncanmcclean Good catch, thanks! You’re right: the query only matched
I've changed it as suggested, and added a test to cover it. See: 48097f6. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Description of the Problem
LocalizeEntryControlleralways creates a new localization and never checks whether one already exists for that site. Each request therefore adds another entry with the sameorigin, so one site can end up with several translations of the same entry.This happens in two common ways:
Once duplicates exist,
$entry->in($site)returns one of them arbitrarily. The CP, the language switcher and the front-end can then show different copies of the same entry.How to Reproduce
What this fix Does
handle,url) is unchanged, so the existing CP code opens the existing localization.The lookup and the creation run inside a
Cache::lockper entry and site, so two requests arriving at the same moment can't both create one. The lock is a separate commit, easy to drop if you'd rather not have it.