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 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

Issue fork drupal-3486797

Command icon 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

alecsmrekar created an issue. See original summary.

alecsmrekar’s picture

Title: Translating path aliases in workspace does not work » Updating path alias language in workspace does not work
alecsmrekar’s picture

alecsmrekar’s picture

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

alecsmrekar’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

Thanks for reporting

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

shalini_jha’s picture

Assigned: Unassigned » shalini_jha

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

shalini_jha’s picture

Assigned: shalini_jha » Unassigned
Status: Needs work » Needs review

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
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests
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.

catch made their first commit to this issue’s fork.

amateescu’s picture

+1 for the RTBC. I added this in #3478240: Improve performance for path_alias queries in a workspace 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:...
catch’s picture

Version: 11.x-dev » 11.1.x-dev
Status: Reviewed & tested by the community » Fixed

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.