- 🇮🇳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
over 1 year ago 4:50pm 4 July 2023 - last update
over 1 year ago 29,782 pass, 14 fail - last update
over 1 year ago Build Successful - last update
over 1 year ago Custom Commands Failed - last update
over 1 year 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
7 months 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
6 months ago 8:58am 6 June 2024 - Status changed to Needs work
6 months 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
6 months ago 9:08am 6 June 2024 - Status changed to Needs work
6 months 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.
- 🇮🇳India prashant.c Dharamshala
Tried to reproduce the issue based on the steps mentioned in the issue summary, I am able to replicate the issue but as per the issue summary
(even trying to access via /node/nid, because I'm redirected to the alias)
, this is not the case atleast in11.x
- When trying to access using
/node/[nid]/
it is opening the correct node page - When trying to access using the node alias it is always opening the node i.e node of the content type in which
Sites's default language(English)
option was selected.
- When trying to access using
- Merge request !8462Same alias for different nodes in the non-default language → (Open) created by prashant.c
- 🇮🇳India prashant.c Dharamshala
It still needs some work :
- MR needs to be reviewed.
- Some existing tests are failing
- As per #21 a new test case needs to be written.
- First commit to issue fork.
- 🇮🇳India arunkumark Coimbatore
arunkumark → changed the visibility of the branch 3091547-same-alias-nodefault to hidden.
- 🇧🇷Brazil cjunior
Hey guys. I'm attaching here the latest version of this fix.
- 🇦🇺Australia pameeela
As I noted in #9, this certainly does not meet the definition of critical → and I don't believe it fits major either.
- 🇮🇳India arunkumark Coimbatore
@cjunior already MR is available please convert your patch into the MR.