Translating unpublished content creates a published tranlsation

Created on 16 December 2024, about 1 month ago

Problem/Motivation

  1. When I create unpublished content in one language and use the AI Translate sub-module to generate it in a different language, the content is immediately published.
  2. I can delete that published content, but when I return to the Translations tab, the content is still there.
  3. Normally I can delete a translation even if it's unpublished. When it has been translated by AI Translate, there is a message to say I can only delete published content, so this seems to be a conscious decision.
    The "Delete translation" action is only available for published translations.

These three issues seem related given the intentional message, so raising as a single issue.

If I manually unpublished that AI translated content and come back to the Translate tab, I can no longer delete it and the Translate tab looks like this (ignore the irrelevant checkbox here):

When I translate content "manually" (old school!) using Drupal core, I can delete unpublished content.

When using Core Translate the Translate tab looks like this:

This is on a Unami basic install. I am not using Drupal Workflows at this point.

Steps to reproduce

  1. Create content in English.
  2. Save as unpublished.
  3. Hit the Translate tab.
  4. Click the auto button for Spanish.
  5. The content is translated but is automatically published.
  6. If I delete that published AI translation, I see a warning and confirm the deletion of the Spanish translation, but when I return to the Translate tab, that translation is still listed and has not been deleted.

Proposed resolution

Mirror what core does with regards to status and the ability to delete revisions.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Other Submodules

Created by

🇬🇧United Kingdom dunx

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

Merge Requests

Comments & Activities

  • Issue created by @dunx
  • 🇬🇧United Kingdom dunx

    I played a bit more now and the above delete stuff no longer looks like my screenshots. I'm not a big user of core translate, so I am not overly familiar with how it is supposed to work. I can no longer see the Delete option on unpublished content (clearly shown in the screenshot above) and when I do delete a published translation, it is not deleted.

    Regardless... the issue with the initial creation as published remains extant.

  • 🇩🇪Germany marcus_johansson

    marcus_johansson changed the visibility of the branch 3494285-translating-unpublished-content to hidden.

  • 🇩🇪Germany marcus_johansson

    I escalated the issue itself, because its a obvious flaw if it does this. I tested with beta5 and could not replicate the issue. Could you try to update to beta5 and see if you still experience the issue?

  • Merge request !341Issue #3494405: Document Deepchat → (Closed) created by marcus_johansson
  • Merge request !342Issue #3494405: Document Deepchat → (Closed) created by marcus_johansson
  • First commit to issue fork.
  • Merge request !379Keep published status. → (Merged) created by valthebald
  • 🇧🇬Bulgaria valthebald Sofia

    When translated entity implements EntityPublishedInterface, keep the published status from original entity.

  • Pipeline finished with Success
    18 days ago
    Total: 260s
    #385720
  • 🇬🇧United Kingdom MrDaleSmith

    Looks good to me

  • 🇬🇧United Kingdom dunx

    I tried to duplicate my original issue on Umami with just the following core and modules enabled:

    • Drupal Core 11.1.1 - long list
    • Admin Toolbar 3.5.1 - toolbar and extras
    • AI (Artificial Intelligence) 1.0.0-beta7 - AI Core and AI Translate
    • Key 8.x-1.19

    I'm logged in as the admin account.

    I created an unpublished article and then clicked on the Translate tab.

    I see the following errors:

    • Error message - Please set a default chat provider & model in the AI module settings.
    • Error message - Warning: Undefined array key 1 in Drupal\ai_translate\Form\AiTranslateForm->buildForm() (line 116 of modules/contrib/ai/modules/ai_translate/src/Form/AiTranslateForm.php).

    Stack trace is:

    TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/html/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\Component\Utility\Html::escape() (line 431 of core/lib/Drupal/Component/Utility/Html.php).
    Drupal\Component\Render\FormattableMarkup::placeholderEscape() (Line: 187)
    Drupal\Component\Render\FormattableMarkup::placeholderFormat() (Line: 195)
    Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)
    Drupal\Core\StringTranslation\TranslatableMarkup->__toString() (Line: 203)
    Drupal\Core\Utility\LinkGenerator->doGenerate() (Line: 180)
    Drupal\Core\Utility\LinkGenerator->generate() (Line: 164)
    Drupal\Core\Link->toString() (Line: 128)
    Drupal\ai_translate\Form\AiTranslateForm->buildForm()
    call_user_func_array() (Line: 528)
    Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 219)
    Drupal\Core\Form\FormBuilder->getForm() (Line: 19)
    Drupal\ai_translate\Controller\ContentTranslationControllerOverride->overview()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

    I want to use Open AI, but visiting the link displayed under "Default providers" at /en/admin/config/ai/settings to /en/admin/config/ai/providers gives me an access denied error. I am admin.

    Ooops... so I'd missed the ai_provider_openai module, but an access denied error doesn't seem very helpful.
    I installed and enabled that module.
    I added my Open AI key via /en/admin/config/system/keys and configured ai_provider_openai to use that key at /en/admin/config/ai/providers/openai

    That access denied error has gone away :)

    I click on the Translate tab again. Same two errors.

    Ooops... I haven't configured AI Translate to use Open AI yet.
    Dropdown at /en/admin/config/ai/ai-translate says to use the "Default from AI Module (chat)", which is just as well as there's no AI option under "Translate Text" at AI settings (/en/admin/config/ai/settings) which is what I was expecting to have to configure.
    So I configure the Chat at that same URL to use Open AI and gpt-3.5-turbo.

    I click the Translate tab again. Hoorah, no errors.

    I click on "Translate using gpt-3.5-turbo" to create a Spanish translation. That works.

    But, it's still Published when the original English is Not published.

    This feels like a fail to me.

    Should I raise the other errors as separate issues?

  • 🇧🇬Bulgaria valthebald Sofia

    @dunx: You get published translation with applied patch too?

  • 🇬🇧United Kingdom dunx

    I tested it with AI (Artificial Intelligence) 1.0.0-beta7 as noted above. I was asked to retest in beta5 at #7. The issue is still present in beta7. The patch is not present in beta7. Shall I apply and retest?

  • 🇬🇧United Kingdom dunx

    After I applied that patch, it worked as expected:

    1. Created some English content - not published.
    2. I used the AI translate to Spanish link on the Translate tab.
    3. That created the Spanish content - also unpublished.

    I think that change is ready to go.

  • 🇬🇧United Kingdom dunx

    I was also able to delete the Spanish translation, which I couldn't do before the patch was applied. I don't think that's strictly related, but an improvement anyway.

  • 🇧🇬Bulgaria valthebald Sofia

    @dunx, those are exactly the steps to confirm the patch is working, thank you!
    I dare move it back to RTBC (I know, formally I shouldn't do it as a patch author, but there was no change in the code, only clarification of the review process)

  • 🇩🇪Germany marcus_johansson

    Sounds good Valery and thanks both, its getting merged.

Production build 0.71.5 2024