Do not fatal when trying to submit a content entity translation twice.

Created on 9 June 2016, over 8 years ago
Updated 6 February 2023, almost 2 years ago

Problem/Motivation

If a user tries to submit a translation to the same language of a given content entity twice a 500 Error Page is returned. Even when it's not a too common scenario it would be better to show a useful message and a real page to end users.

Steps to reproduce:

  • Install Drupal with the Standard Profile in English
  • Activate Language and Content Translation modules
  • Add Spanish language
  • In Regional > Content Language activate Content and make Basic page translatable
  • Create a new Page in English
  • Click the translate tab, and Add a Spanish translation
  • Open in a new tab the same path that the add translation form
  • Save the form in one tab and, when finished, save the second one

Proposed resolution

Catch the Exception, redirect and show a message to the user, and don't show a blank page with an error message.

Remaining tasks

  1. Review the proposed solution and patch.
  2. Add tests

User interface changes

Adding an error message.

API changes

None.

Data model changes

None.

๐Ÿ› Bug report
Status

Needs review

Version

10.1 โœจ

Component
Content translationย  โ†’

Last updated 3 days ago

No maintainer
Created by

๐Ÿ‡ช๐Ÿ‡ธSpain jsbalsera Cรณrdoba, Spain

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request โ†’ as a guide.

    Confirmed the issue in D10 and that patch #17 addresses it.

    @Gabor Hotjsy does #17 answer your comments/questions?

    Ran test locally to make sure they failed and got

    Behat\Mink\Exception\ExpectationException : Current response status code is 500, but 200 expected.
    

    Triggered #17 for D10.1 tests.

  • Status changed to RTBC almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    All green!

    Forgot to remove the tests tag as they were added in #17

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    The remaining tasks state that this needs a review of the proposed solution and patch. I do not see a review of the patch. There is also another proposed solution in #17 that needs to be discussed.

    I took a brief view of the patch.

    1. +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php
      @@ -376,7 +377,14 @@ public function add(LanguageInterface $source, LanguageInterface $target, RouteM
      +      // If the target language is lock redirect and show a helpful message.
      

      I think the grammar hear needs to be improved.

    2. +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php
      @@ -376,7 +377,14 @@ public function add(LanguageInterface $source, LanguageInterface $target, RouteM
      +      $this->messenger()->addError($this->t('You are redirected to translations overview page as translation already exists.'));
      

      This doesn't read well to me.

    3. +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php
      @@ -166,4 +166,19 @@ public function testContentTranslationOverviewAccess() {
      +   * Ensure that content translation add URL should throw error when we try to
      +   * access even though translation exits.
      

      This does not meet coding standards. The Summary line is to be < 80 char, among other things.

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sahil.goyal

    Addressed the comment #24 in this patch and attaching the interdiff along, made clear off php coding standard issues.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia _utsavsharma

    Tried to fix CCF for #27.

Production build 0.71.5 2024