Problem/Motivation

The "Hide non translatable fields on translation forms" option, that has been introduced in #2878556: Ensure that changes to untranslatable fields affect only one translation in pending revisions doesn't apply to Url alias field. That produces more issues in case Url Alias field is marked as non-translatable - url alias added in original language doubles every time new translation is added.

Steps to reproduce:

  1. Install standard
  2. Add second language
  3. Enable content translation for article, uncheck translations for Url Alias, check "Hide non translatable fields on translation forms"
  4. Go to article creation form
  5. Create an article, add an url alias
  6. Create a node translation from translations tab - observe that url alias field is present and it's prefilled with value from english version of the node
  7. Save translation and go to /admin/config/search/path - observe two entries with same alias, system path and language

Proposed resolution

Hide Url alias field if non-translatable

Remaining tasks

Test
Patch
Review

User interface changes

Url alias field is now hidden from entity translation form in case the field is marked as non-translatable and "Hide non translatable fields on translation forms" is checked.

API changes

n/a

Data model changes

n/a

Release notes snippet

CommentFileSizeAuthor
#7 3017157-7-TEST-ONLY.patch3.23 KBzaporylie

Comments

zaporylie created an issue. See original summary.

zaporylie’s picture

That produces more issues in case Url Alias field is marked as non-translatable - url alias added in original language doubles every time new translation is added.

Just tried to hack EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck to make sure the path field, even if computed, doesn't fall into the same restrictions as the rest of the computed field. This successfully hides the field from the entity translation form but new URL alias is created anyways (in PathItem::postSave()).

matsbla’s picture

I've checked this and can confirm the bug

berdir’s picture

the translatable/untranslatable checkbox doesn't work at all right now. It doesn't matter if it's translatable or not, the alias is *always* per entity language.

See #2689459: If you don't want to translate your URL alias, the original URL alias won't work with your translations. I would close this as a related/duplicate of that and then we'll have to solve that problem there.

The widget might need to hide itself then in that case as the generic code doesn't deal with computed fields.

zaporylie’s picture

Did some research about the saving part - seems like a new alias. with langcode consistent with translation, is enforced by path_entity_translation_create(). That part can be fixed in #2689459: If you don't want to translate your URL alias, the original URL alias won't work with your translations as of your suggestion, but we still have an issue with widget being displayed even though "Hide non translatable fields on translation forms" is checked - and this is the scope for this issue. It seems like the regression was introduced in #2826021: FieldItemList::equals is sufficient from the storage perspective but not for code checking for changes.

berdir’s picture

My point is that right now, showing it is kind of the correct thing to do because the alias really is always translated/per language, no matter which translation setting you have (well, with the fallback, it gets more complicated, as it could be language neutral if it was created as that elsewhere. But that too is consistent no matter how the field is configured).

That does change as soon as we actually respect that setting, then showing it will be a bug. So it would make sense to fix it in the same issue.

zaporylie’s picture

Status: Active » Needs review
StatusFileSize
new3.23 KB

Thank you @Berdir for elaborating on the problem (or the lack of it ). I still believe this is a bug even now and adding a failing test to prove it. The test is basically copied over from PathLanguageTest::testAliasTranslation with the modification - `settings[node][page][fields][path]` is set as untranslatable. I have added following two lines to prove that alias is created in incorrect language:

    // @todo: Remove.
    // Prove that alias is created with the wrong langcode.
    $this->drupalGet($edit['path[0][alias]']);
    $this->assertSession()->pageTextContains($english_node->body->value, 'French alias works with english node.');

Still - the fix to that issue should probably land in #2689459: If you don't want to translate your URL alias, the original URL alias won't work with your translations. My point here is that right now showing a Path widget when the field is non-translatable is a bug.

Status: Needs review » Needs work

The last submitted patch, 7: 3017157-7-TEST-ONLY.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 7: 3017157-7-TEST-ONLY.patch, failed testing. View results

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.