Problem/Motivation

I created a node (in english) with Paragraphs. Then I requested a german translation. Before the translation was completed, I added new paragraphs (mainly media items) to the english original node - they have also been added in between older Paragraphs. Later when I wanted to accept the german translation it led to an unhandled exception:

[%type] (string): InvalidArgumentException
[@message] (string): Field field_text is unknown.
[%function] (string): Drupal\Core\Entity\ContentEntityBase->getTranslatedField()
[%file] (string): /app/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php
[%line] (string): 509
[severity_level] (string): 3
[backtrace] (string): #0 /app/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(490): Drupal\Core\Entity\ContentEntityBase->getTranslatedField('field_text', 'de')
#1 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(397): Drupal\Core\Entity\ContentEntityBase->get('field_text')
#2 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(404): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->doSaveTranslations(Object(Drupal\paragraphs\Entity\Paragraph), Array, 'de')
#3 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(300): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->doSaveTranslations(Object(Drupal\node\Entity\Node), Array, 'de')
#4 /app/web/modules/contrib/tmgmt/src/Entity/JobItem.php(851): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->saveTranslation(Object(Drupal\tmgmt\Entity\JobItem), 'de')
#5 /app/web/modules/contrib/tmgmt/src/Form/JobItemForm.php(361): Drupal\tmgmt\Entity\JobItem->acceptTranslation()
#6 [internal function]: Drupal\tmgmt\Form\JobItemForm->save(Array, Object(Drupal\Core\Form\FormState))
#7 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array)
#8 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#9 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#10 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('tmgmt_job_item_...', Array, Object(Drupal\Core\Form\FormState))
#11 /app/web/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('tmgmt_job_item_...', Object(Drupal\Core\Form\FormState))
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#14 /app/web/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#17 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /app/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array)
#19 /app/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}
[@backtrace_string] (string): #0 /app/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(490): Drupal\Core\Entity\ContentEntityBase->getTranslatedField('field_text', 'de')
#1 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(397): Drupal\Core\Entity\ContentEntityBase->get('field_text')
#2 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(404): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->doSaveTranslations(Object(Drupal\paragraphs\Entity\Paragraph), Array, 'de')
#3 /app/web/modules/contrib/tmgmt/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php(300): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->doSaveTranslations(Object(Drupal\node\Entity\Node), Array, 'de')
#4 /app/web/modules/contrib/tmgmt/src/Entity/JobItem.php(851): Drupal\tmgmt_content\Plugin\tmgmt\Source\ContentEntitySource->saveTranslation(Object(Drupal\tmgmt\Entity\JobItem), 'de')
#5 /app/web/modules/contrib/tmgmt/src/Form/JobItemForm.php(361): Drupal\tmgmt\Entity\JobItem->acceptTranslation()
#6 [internal function]: Drupal\tmgmt\Form\JobItemForm->save(Array, Object(Drupal\Core\Form\FormState))
#7 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array)
#8 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#9 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#10 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('tmgmt_job_item_...', Array, Object(Drupal\Core\Form\FormState))
#11 /app/web/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('tmgmt_job_item_...', Object(Drupal\Core\Form\FormState))
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#14 /app/web/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#17 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /app/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array)
#19 /app/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}

As workaround I removed the Paragraphs that have been added after the translation request and then accepted the german translation. That worked. I then could add the new Paragraphs again.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jzech created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major
Issue tags: -tmgmt

Promoting for more visibility. Paragraphs is one of the most used modules in D8. :-)

We can fix it - for instance by mapping sources with hashes (or UUID per Paragraph), but that's quite a bit of work.

Berdir’s picture

Status: Active » Needs review
Issue tags: -Paragraphs
FileSize
9.51 KB

First step, adds a test that move referenced entities around and improves the code to be able to handle this situation better.

Status: Needs review » Needs work

The last submitted patch, 3: adding_paragraphs_after-2875163-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

Fixed the test fails. Also added tests for removing standard (text) items, for now just ignoring those translations the in that case.

Berdir’s picture

That patch reverted the webform patch, this should be better.

  • Berdir committed 522c936 on 8.x-1.x
    Issue #2875163 by Berdir: Adding Paragraphs after translation request...
Berdir’s picture

Status: Needs review » Fixed

Committed and pushed.

timcosgrove’s picture

As pointed out in #2788697: Check for the existence of the delta of a field when importing translated values into it., this prevents the errors but discards data. That should probably be fixed.

Status: Fixed » Closed (fixed)

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