- 🇮🇳India er.garg.karan Chandigarh
I am also facing this issue.
Steps to reproduce
- Create a content type "Blog". Make sure you choose to show the language selector drop-down on the node create and edit page.
- Set the default language of the content type as "Not Specified".
- Go to blog add form.
- Choose the language as "French" and add a custom URL "/my-custom-url-for-blog".
- Save the node and you will be able to create the blog node.
- Repeat steps #3, #4, and #5 and you will be able to create a new node in French with the same URL "/my-custom-url-for-blog".
Cause
The classDrupal\Core\Path\Plugin\Validation\Constraint\UniquePathAliasConstraintValidator
hasvalidate
function and it checks for the duplicate URL in a particular language. But the variable "$langcode" in line 49 gets the langcode from the path entity and it is always the default language you choose in Step #2. In my case, it is always "Not Specified".
This works fine when you edit one of the blog because by this time, the language of path alias has been set to "French".Propose solution
The language should be used from the language dropdown if it is visible on the node add form. - 🇮🇳India er.garg.karan Chandigarh
I was able to create this patch. It works for multiple versions of Drupal.
- Status changed to Needs review
12 months ago 4:50pm 4 July 2023 - last update
12 months ago 29,782 pass, 14 fail - last update
12 months ago Build Successful - last update
12 months ago Custom Commands Failed - last update
12 months ago 29,424 pass, 14 fail The last submitted patch, 13: same-alias-for-different-nodes-3091547-13.patch, failed testing. View results →
- Status changed to Needs work
20 days ago 8:40am 27 May 2024 - 🇵🇱Poland tivi22
Thanks er.garg.karan for the patch. I needed to adjust it a little, but it worked fine for me.
- 🇮🇳India rajghai
Upon using the patch → , I was getting a below error while creating a new node:
Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Input value "langcode" contains a non-scalar value. in Symfony\Component\HttpKernel\HttpKernel->handle() (line 83 of /mnt/www/html/marketing7dev/vendor/symfony/http-kernel/Htt
pKernel.php).I have updated the patch.
- Status changed to Needs review
10 days ago 8:58am 6 June 2024 - Status changed to Needs work
10 days ago 9:05am 6 June 2024 The Needs Review Queue Bot → tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request → . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
- Status changed to Needs review
10 days ago 9:08am 6 June 2024 - Status changed to Needs work
6 days ago 5:46pm 10 June 2024 - 🇺🇸United States smustgrave
Recommend using MRs as those get auto ran against the tests
Also see most likely will need a test case.