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/Motivation
On a multilingual site, the same path alias cannot be set for two different languages.
Steps to reproduce
- Enable the Language module
- Add the English and Japanese languages to the site
- Set the URL prefix to /en for English and /jp for Japanese (in
/en/admin/config/regional/language/detection/url
) - Allow the language to be changed for the Basic page content type (tick the "Show language selector on create and edit pages" checkbox in the "Language settings tab" in
/en/admin/structure/types/manage/page
) - On
/en/node/add/page
set the language to English, put /demo as path alias; and save - On
/en/node/add/page
set the language to Japanese, set /demo as path alias, and save - The alias /demo is already in use in this language will appear as error message
Notice the "...in this language" part of the error message (although you have selected a different language when saving the second page).
Comment | File | Size | Author |
---|---|---|---|
#52 | interdiff_48-52.txt | 1.65 KB | murilohp |
#52 | 3179599-52.patch | 3.07 KB | murilohp |
| |||
#48 | interdiff_42-48.txt | 1.33 KB | murilohp |
#48 | 3179599-48-test-only.patch | 1.47 KB | murilohp |
#42 | interdiff_37-42.txt | 883 bytes | murilohp |
Issue fork drupal-3179599
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Oscaner CreditAttribution: Oscaner at CI&T commentedComment #3
Oscaner CreditAttribution: Oscaner at CI&T commentedComment #4
kishor_kolekar CreditAttribution: kishor_kolekar as a volunteer and at QED42 for Drupal India Association commentedComment #6
shivam kaushal CreditAttribution: shivam kaushal at OpenSense Labs commentedComment #7
shivam kaushal CreditAttribution: shivam kaushal at OpenSense Labs commentedComment #9
LendudeThanks for reporting and thanks for working on this.
Moving this to the Drupal core version that is currently receiving bug fixes.
We will need an automated test to demonstrate this issue occurs in a clean Drupal install and the fix needs work because it is currently failing a fair number of tests.
Comment #10
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedRe-roll patch for 9.1.x.
Comment #11
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedComment #12
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedFixed the phpcs issue.
Comment #14
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedFixing fail tests.
Comment #16
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedThe following patch file is working fine for me
Comment #18
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedThe following patch file is working fine in drupal 8.9.x
https://www.drupal.org/files/issues/2021-06-07/path_alias.patch
Comment #19
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #20
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedcommand related issues are fixed
Comment #21
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #22
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedfixed fail tests
Comment #23
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedchanges are modified to support both 8.9 and 9
Comment #26
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedFixing fail tests.
Comment #27
apadernoComment #29
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedFixing fail tests.
Comment #30
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #31
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #32
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #33
apadernoComment #34
apadernoWe don't use variable names ending with an underscore.
$aliasStatus
isn't a self-descriptive name. Is really necessary to check if the path alias is for a node? The same issue would be present whether the path alias is for a different entity.There is no need to show the previous code as commented line.
Comment #35
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedDrupal 7:
User have a choice to create multi-language pages in any content type.
Ex : en/demo.html - 'Article' content-type and jp/demo.html in 'Basic page' content-type - its possible and it works
Drupal 8 and 9 :
User don't have a choice and should must create multi-language pages in same content-type of source language.
Ex : /en/demo.html - 'Article' content-type and /jp/demo.html in 'Basic page' content-type - its not possible
Comment #36
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #37
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #38
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #40
parisekComment #41
joachim CreditAttribution: joachim at Factorial GmbH commentedLocal variable names should be in camel case.
Also the service should be injected.
Also, as noted already, needs a test.
Comment #42
murilohp CreditAttribution: murilohp at CI&T commentedHey @joachim thanks for the review!
Local variable names should be in camel case.Done! Changed the variable to be snake_casevalidateFormElement
is staticComment #43
joachim CreditAttribution: joachim at Factorial GmbH commented> The function validateFormElement is static
Oh, whoops. You're right, it can't be injected into a static!
Thanks for the fix!
Comment #46
klonosUpdating issue summary with some details and slightly reordering steps to what makes sense.
Comment #47
Tharunkumar Nunna CreditAttribution: Tharunkumar Nunna as a volunteer commentedComment #48
murilohp CreditAttribution: murilohp at CI&T commentedThanks for IS update @klonos, with that information I was able to create a test and replicate the bug. Here's a new patch, and a test-only patch.
Comment #50
jonathanshawNice work @murilohp
I don't really like this as a way of verifying the outcome here. I'd prefer to see something that proves more explicitly that we really have 2 nodes with the correct different paths.
Otherwise RTBC.
Comment #51
Nikhil_110 CreditAttribution: Nikhil_110 at Srijan | A Material+ Company commentedRe-roll patch #48 and apply changes #50
Comment #52
murilohp CreditAttribution: murilohp at CI&T commentedHey! Thanks for the review @jonathanshaw! I've updated the test, now, the test will test,validate the page and also asserts the path alias.
@Nikhil_110, thanks for the patch, but I didn't get what you've done, you basically changed an unrelated test, so this new patch is based on #48.
Comment #53
joachim CreditAttribution: joachim as a volunteer commentedThis could do with a comment to explain what it's doing.
Currently it looks like it's part of the 'Trim...' code.