Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem:
- create content named "test" in a (any) language
- create content named "test" in language neutral
Result:
the alias "test" will be assigned to both content items.
Cause:
In path_pathauto_is_alias_reserved the current code makes sure that a localised alias does not interfere with any language neutral alias, which is fine.
however, it should check if _any_ alias exists when creating language neutral content.
Patch will follow
(there is some similarity between this and D6 issue #593048: _pathauto_alias_exists handles language-neutral aliases wrong like comment #25)
Comment | File | Size | Author |
---|---|---|---|
#30 | pathauto-language_neutral_dupe-2067191-27-tests.patch | 801 bytes | bneil |
#30 | pathauto-language_neutral_dupe-2067191-27-complete.patch | 2.04 KB | bneil |
Comments
Comment #1
rv0 CreditAttribution: rv0 commentedPatch breaks up the query adding the language conditionally
Also removes order by (why would we want to order something we're casting to boolean later on?)
Comment #2
René-Marc Simard CreditAttribution: René-Marc Simard commentedI confirm that this patch works as described. Thanks to this change I no longer end-up with colliding aliases when a language-neutral alias is being created while an identical language-specific one already exists. path_pathauto_is_alias_reserved() now properly flags the proposed alias as being reserved which leads to pathauto_alias_uniquify() testing iterations until a unique suffix is found to prevent collisions, as expected.
Thanks for the fix!
Comment #3
rv0 CreditAttribution: rv0 commentedThanks for the review @René-Marc Simard
Looking at this almost one year later, I don't know why I did not use db_select in the patch, would be a bit cleaner.
Comment #4
DamienMcKennaComment #5
DamienMcKennaThe only change this makes vs the original is that it comment has been reformatted to 80 chars, per the Drupal coding standards.
Comment #7
MiroslavBanov CreditAttribution: MiroslavBanov commentedI am not sure why more people are not reporting this problem. Patch #5 fixes it for me.
Comment #8
Dave ReidThis patch shoud definitely be converting this to db_select() now. I don't want to be have SQL strings constructed together with strings like this.
Comment #9
Leeteq CreditAttribution: Leeteq commentedComment #10
Martijn Houtman CreditAttribution: Martijn Houtman commentedPatch rewritten to follow db_select() standards.
Comment #11
rv0 CreditAttribution: rv0 commentedLooks good to me
Comment #14
Martijn Houtman CreditAttribution: Martijn Houtman commentedFixes use of $langcode, rather than $language.
Comment #15
rv0 CreditAttribution: rv0 commentedComment #17
stefan.r CreditAttribution: stefan.r commentedComment #18
stefan.r CreditAttribution: stefan.r commentedComment #19
kiricou CreditAttribution: kiricou commentedHi,
I have the same pb with the recommended release 7-1.2
I try the 7-1.x-dev and same bug, and when I apply successfully your patch, it's work
Thank a lot,
I hope the dev version is stable because I put it in production.
Sim
Comment #20
stefan.r CreditAttribution: stefan.r commentedThanks for the review @kiricou. Can anyone else review so we can RTBC this?
Comment #21
Dave ReidThis needs a test case to confirm it works and will not regress in the future.
Comment #22
bneil CreditAttribution: bneil commentedSetting to needs work per #21
Comment #23
bneil CreditAttribution: bneil commentedComment #24
bneil CreditAttribution: bneil commentedHere's a revised patch that adds a test to the end of the testLanguageAliases() method. It ensures that when a language neutral node is saved with what will end up being the same alias as a node with its language defined, the alias suffix is incremented correctly.
Comment #25
bneil CreditAttribution: bneil commentedComment #26
bneil CreditAttribution: bneil commentedComment #28
stefan.r CreditAttribution: stefan.r commentedIndentation is off lines 728 & 729 :)
Otherwise patch looks good.
Comment #29
bneil CreditAttribution: bneil commentedAh, you're right! Here are revised patches with the indentation fix.
Comment #30
bneil CreditAttribution: bneil commentedI noticed my comment was wrong for the test. the -1 is a suffix, not a prefix.
Comment #33
bneil CreditAttribution: bneil commentedComment #34
stefan.r CreditAttribution: stefan.r commentedThanks, patch looks good now. If anyone else can review this can be RTBC'ed
Comment #35
fullerja CreditAttribution: fullerja commentedComplete patch in #30 works for me. RTBC'ing based on this and #34.
Comment #36
baso CreditAttribution: baso commentedPatch #30 (complete version) also works for me. Thanks.
Comment #37
osopolarWorks for me too, thanks.
Comment #41
Dave ReidCommitted #30 to 7.x-1.x. Thanks!