Translating path aliases in workspace does not work

Created on 11 November 2024, 3 months ago

Problem/Motivation

When changing the language an existing path alias inside of a workspace, the path alias stops working.

Steps to reproduce

1. drush si
2. drush en -y workspaces content_translation
3. drush uli
4. Go to /admin/config/regional/language and add the Spanish language
5. Go to /admin/config/regional/content-language and enable translation for "Content", ensure to check "Article" under the "Content" fieldset
6. Add a new article node, and set the path alias to /test before saving it
7. Save the node
8. Switch to the staging workspace
9. Go to /admin/config/search/path/edit/1 and update the path alias to use "Not specified" language, save it.
10. Go to /test

See a 404 page.

Proposed resolution

The second proposed solution here 🐛 Improve performance for path_alias queries in a workspace Active should be reverted. That additional language condition causes the repository to not find a matching path alias if the langcode in the base & revision tables is different. This essentially means that changing the language of a path alias in a workspace does not work.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

workspaces.module

Created by

🇸🇮Slovenia alecsmrekar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @alecsmrekar
  • Pipeline finished with Failed
    3 months ago
    Total: 573s
    #335436
  • 🇸🇮Slovenia alecsmrekar

    Test failure does not seem related:
    Drupal\Tests\comment\Functional\CommentPreviewTest 0 passes 94s 1 fails

  • 🇺🇸United States smustgrave

    Thanks for reporting

    Think next step will be to add test coverage showing the problem and that the change fixes it.

  • 🇮🇳India shalini_jha

    I have replicated this issue, and the merge request fixes it. I will work for the test coverage.

  • Pipeline finished with Failed
    3 months ago
    Total: 81s
    #344335
  • Pipeline finished with Failed
    3 months ago
    Total: 586s
    #344339
  • Pipeline finished with Success
    3 months ago
    Total: 455s
    #344352
  • 🇮🇳India shalini_jha

    I have added test coverage for showing this issue, pipeline is green so moving this NR.
    Kindly review.

    Failing test :

    There was 1 failure:
    
    1) Drupal\Tests\workspaces\Functional\PathWorkspacesTest::testPathAliasesWithTranslation
    Behat\Mink\Exception\ExpectationException: Current response status code is 404, but 200 expected.
    
    /var/www/html/vendor/behat/mink/src/WebAssert.php:888
    /var/www/html/vendor/behat/mink/src/WebAssert.php:145
    /var/www/html/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:345
    /var/www/html/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:331
    
  • 🇺🇸United States smustgrave
    1) Drupal\Tests\workspaces\Functional\PathWorkspacesTest::testPathAliasesWithTranslation
    Behat\Mink\Exception\ExpectationException: Current response status code is 404, but 200 expected.
    /builds/issue/drupal-3486797/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3486797/vendor/behat/mink/src/WebAssert.php:145
    /builds/issue/drupal-3486797/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:345
    /builds/issue/drupal-3486797/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:331
    FAILURES!
    Tests: 3, Assertions: 130, Failures: 1.
    Exiting with EXIT_CODE=1
    

    Test coverage appears to be there so removing that tag.

    Reviewing code and nothing stands out.

  • Status changed to RTBC 2 days ago
  • First commit to issue fork.
  • 🇷🇴Romania amateescu

    +1 for the RTBC. I added this in 🐛 Improve performance for path_alias queries in a workspace Active thinking that path aliases are translatable, but they're not :)

    • catch committed 3465f9c1 on 11.x
      Issue #3486797 by alecsmrekar, shalini_jha, smustgrave, amateescu:...
    • catch committed 315c9087 on 11.1.x
      Issue #3486797 by alecsmrekar, shalini_jha, smustgrave, amateescu:...
  • 🇬🇧United Kingdom catch

    Committed/pushed to 11.x, and cherry-picked to 11.1.x, thanks!

    This doesn't cherry-pick to 10.5 cleanly so leaving fixed against 11.1.x for now. If you strongly feel it needs a 10.5 backport, please re-open with a backport MR.

Production build 0.71.5 2024