Problem/Motivation

Translation is not deleted when following edit link from admin/content page.

Steps to reproduce

- Enable Content Translation module
- Add additional language
- Set up translation for default 'Basic page' node type (or any else)
- Create a node and add translation for it
- Visit /admin/content page
- Click on edit link for previously added node translation
- Click on "Delete translation" button

Expected result:
- User should be redirected to node delete form (/node/NID/delete)

Actual result:
- User redirected to url that set on 'destination' url query parameter
- Translation isn't removed

Proposed resolution

Convert the button into a link because essentially it does a redirect. This is an approach used by other forms providing Delete operations.

Remaining tasks

Update the change record. Write a change record for a Drupal core issue

User interface changes

API changes

Data model changes

Release notes snippet

Sorry, can't find any mentions for exact behavior, so I created this one

Comments

myLies created an issue. See original summary.

mylies’s picture

and a raw patch for it
use this one carefully, because it can affect on entities that can provide some contrib\custom modules that have own ContentTranslationHandler implementation

mylies’s picture

Issue summary: View changes
mylies’s picture

mylies’s picture

Issue tags: +destination

tests seems to be fixed, but I leave this issue in active status - not sure that this way is correct one

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.

spadxiii’s picture

Status: Active » Needs review

Set it to needs review so this gets a few more views. The patch seems to work.

akasake’s picture

akasake’s picture

spadxiii’s picture

Did a quick re-roll of the last patch for drupal 9.1

spadxiii’s picture

Should've done a reroll for drupal 9.2 ... ah well, here it is :)

spadxiii’s picture

It looks like I made a mistake when re-rolling the patch. Here's a working on for 9.2.x

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
ravi.shankar’s picture

Patch #12 doesn't need to reroll as it's getting applied cleanly on Drupal 9.3.x.

owilliwo’s picture

I'm not able to apply patch #16 on a Drupal 9.3.9
Thought it was because of other patches applied to Drupal Core, but I've been testing to apply only this patch, and it's not applicable, even alone.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new6.92 KB

A re-rolled patch against the latest 9.3.x.

Status: Needs review » Needs work

The last submitted patch, 19: 3108102-19.patch, failed testing. View results

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.

quietone’s picture

Still valid on Drupal 10.1.x, standard install.

ameymudras’s picture

Version: 9.5.x-dev » 10.1.x-dev
StatusFileSize
new6.93 KB

Re rolling for 10.1.0, couldn't generate an interdiff

ameymudras’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.25 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

_pratik_’s picture

Status: Needs work » Needs review
StatusFileSize
new7.29 KB
new538 bytes

Fix as per #24
thanks

Status: Needs review » Needs work

The last submitted patch, 27: 3108102-27.patch, failed testing. View results

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lauriii’s picture

Priority: Minor » Major
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new8.17 KB
new907 bytes
lauriii’s picture

StatusFileSize
new8.41 KB
new3.94 KB

Converted the button into action link in Claro and changed to use property promotion.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Hate to be that guy but can the IS be updated with the proposed solution.

Following the steps though I can confirm the issue and that patch #31 fixes it.

Besides the IS update should it be mentioned why

protected RequestStack $requestStack is protected when the rest aren't?

lauriii’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Added the proposed solution to the IS.

protected RequestStack $requestStack is protected when the rest aren't?

That's because it's using PHP constructor property promotion. 😊

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Gotcha!

lauriii’s picture

Issue tags: +Field UX
longwave’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -119,8 +121,10 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
    +  public function __construct(EntityTypeInterface $entity_type, LanguageManagerInterface $language_manager, ContentTranslationManagerInterface $manager, EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user, MessengerInterface $messenger, DateFormatterInterface $date_formatter, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository, protected RequestStack $requestStack) {
    

    We need backward compatibility on the $requestStack argument, in the case a subclass calls the parent constructor without this argument.

  2. +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -772,23 +780,31 @@ public function entityFormDelete($form, FormStateInterface $form_state) {
    -  public function entityFormDeleteTranslation($form, FormStateInterface $form_state) {
    

    This is a public method so we should leave it in place and deprecate it for removal in 11.0.0.

  3. +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -772,23 +780,31 @@ public function entityFormDelete($form, FormStateInterface $form_state) {
    +      $options['query']['destination'] = $request->query->get('destination');
    

    As we only need destination here, can/should we use the redirect.destination service, instead of injecting the entire request stack?

longwave’s picture

Issue tags: +ddd2023
lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new8.86 KB
new5.18 KB

Thanks @longwave! This should address all of the feedback from #36. 🤞

penyaskito’s picture

StatusFileSize
new4.87 KB
new5.31 KB

Screenshots before and after. This not only fixes an issue, but it's a major UX improvement.

Screenshot before this patch shows a button with Delete translation in Spanish, but doesn't show it as a dangerous not reversible operation

Screenshot after this patch shows a link with Delete translation in Spanish, styling it as a dangerous not reversible operation

penyaskito’s picture

  1. +++ b/core/modules/content_translation/src/ContentTranslationHandler.php
    @@ -130,6 +134,10 @@ public function __construct(EntityTypeInterface $entity_type, LanguageManagerInt
    +      @trigger_error('Calling ContentTranslationHandler::__construct() without the $redirectDestination argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3375487', E_USER_DEPRECATED);
    

    Verified the link points to the right change record 👍🏾

  2. +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
    @@ -379,7 +379,7 @@ protected function doTestTranslationDeletion() {
    -    $this->submitForm([], 'Delete translation');
    +    $this->clickLink('Delete translation');
    

    Our existing test didn't find the bug here. So should we have a new test that actually adds a redirect destination query fragment, to ensure this works?

  3. +++ b/core/themes/claro/claro.theme
    @@ -414,6 +414,10 @@ function claro_form_alter(array &$form, FormStateInterface $form_state, $form_id
    +  if (isset($form['actions']['delete_translation']['#type']) && $form['actions']['delete_translation']['#type'] === 'link' && !empty($build_info['callback_object']) && $build_info['callback_object'] instanceof EntityForm) {
    +    $form['actions']['delete_translation'] = _claro_convert_link_to_action_link($form['actions']['delete_translation'], 'trash', 'default', 'danger');
    +  }
    

    Does this need specific claro tests?

lauriii’s picture

StatusFileSize
new9.54 KB
new1.16 KB

Paired with @penyaskito to add test case for #40.2.

#40.3: We don't usually add test coverage for UI enhancements.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Congrats! You earned the "I can write a test for that in 10 minutes badge!"

RTBC, thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 41: 3108102-41.patch, failed testing. View results

penyaskito’s picture

Status: Needs work » Reviewed & tested by the community
1) Drupal\Tests\workspaces\Functional\PathWorkspacesTest::testPathAliases
Failed asserting that a boolean is not empty.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:109
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

2) Drupal\Tests\workspaces\Functional\PathWorkspacesTest::testPathAliasesUserSwitch
Failed asserting that a boolean is not empty.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/workspaces/tests/src/Functional/PathWorkspacesTest.php:152
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

FAILURES!
Tests: 3, Assertions: 126, Failures: 2.

Looked pretty random to me, lauriii requeued.

longwave’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 41: 3108102-41.patch, failed testing. View results

longwave’s picture

Status: Needs work » Reviewed & tested by the community

Saving issue credits, and back to RTBC after some random fails.

  • longwave committed c61d707e on 11.x
    Issue #3108102 by lauriii, SpadXIII, akasake, myLies, _pratik_, Suresh...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed c61d707ed4 to 11.x. Thanks!

Unfortunately not eligible for backport because of the addition to the ContentTranslationHandler constructor.

Status: Fixed » Closed (fixed)

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

quietone’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work
Issue tags: +Needs change record updates

The change records for this issue is the same as the deprecation message. I suggest someone add more explanation and perhaps a code example.

miiimooo’s picture

The patch https://git.drupalcode.org/project/drupal/commit/c61d707ed4.patch applies cleanly against 10.1

    https://git.drupalcode.org/project/drupal/commit/c61d707ed4.patch (3108102 - Destination url query param affects on form translation delete submission)
patch '-p2' --no-backup-if-mismatch -d 'web/core' < '/tmp/652fa878032e9.patch'
patching file modules/content_translation/src/ContentTranslationHandler.php

patching file modules/content_translation/tests/src/Functional/ContentTranslationRevisionTranslationDeletionTest.php

patching file modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php

patching file themes/claro/claro.theme

Hunk #1 succeeded at 419 (offset 5 lines).
heddn’s picture

miiimooo’s picture

Status: Needs work » Reviewed & tested by the community

This should be closed since it has been committed https://git.drupalcode.org/project/drupal/-/commit/c61d707ed4 to 10.2+

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work

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

penyaskito’s picture

Status: Needs work » Fixed

At this point I guess better to change this to Fixed. We can always update the change records, but even short they are enough as contain the direct method replacement.

Status: Fixed » Closed (fixed)

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

luenemann’s picture

Version: 11.x-dev » 10.2.x-dev
quietone’s picture

The updates to the CR did not happen and now that 10.2 is no longer supported, I am removing the tat.