After updating drupal core to 8.3.3 I get the following error:

Drupal\Core\Entity\EntityStorageException: Update existing 'node' entity revision while changing the revision ID is not supported. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 768)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 215)
Drupal\lingotek\LingotekContentTranslationService->setTargetStatus(Object, 'en', 'EDITED') (Line: 132)
Drupal\lingotek\LingotekContentTranslationService->setSourceStatus(Object, 'EDITED') (Line: 250)
lingotek_entity_update(Object)
call_user_func_array('lingotek_entity_update', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 169)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 441)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 470)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 326)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 395)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 768)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 286)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('node_page_vertical_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 118)
Drupal\cdn\StackMiddleware\DuplicateContentPreventionMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vomiand created an issue. See original summary.

vomiand’s picture

This seems to be happening cause entity->save is being called while executing hook_update of the same entity.

vomiand’s picture

Issue summary: View changes
Status: Active » Needs review
penyaskito’s picture

The 8.x-2.x branch was created for getting this fixed. Please test that one for your use case.
The attached patch will break Lingotek module functionality.

vomiand’s picture

The 8.x-2.x branch update somehow breaks the link between nodes and lingotek.
All translations have this status:
Translation exists, but it is not being tracked by Lingotek.

Can we have this fix for 8.x-1.x until 8.x-2.x gets fixed or something?

penyaskito’s picture

Did you run drush updb or visited the update page in that site? If not, that's an unknown bug that we need to tackle.
Could you please test in a dev environment that you can recreate from a backup later just in case?

penyaskito’s picture

We cannot fix this in 8.x-1.x, because it's an architectural problem. The 8.x-2.x branch was built exactly for fixing this issue and other related to versioning that were caused because of storing metadata in the entity itself.

penyaskito’s picture

Re-reading this patch looks safe to commit. However, it would be great having a test showing the problem.

vomiand’s picture

When running drush updb I get the error reported here:
https://www.drupal.org/node/2878924

What I did is add another condition in the if from line 281 from lingotek.install:
if ($entity && isset($entity->lingotek_document_id) && isset($entity->lingotek_profile->entity)) {

which ran the update, but got translations into the state of: 'Translation exists, but it is not being tracked by Lingotek.'.

jrockowitz’s picture

The patch did not resolve the issue for me. I ran into the same error for some custom code and had to use the @internal ContentEntityInterface::updateLoadedRevisionId method to get the second entity save to work.

The attached patch is just a work-around and not a long term solution. As soon as 8.2 has a tagged release I will switch over to it.

Status: Needs review » Needs work

The last submitted patch, 10: when_updating_to_core-2878570-10.patch, failed testing.

penyaskito’s picture

Status: Needs work » Needs review

Requeued #2 with "PHP 7 & MySQL 5.5, D8.3". Those are failing with HEAD with the same error, if this passes I will commit it.

penyaskito’s picture

As I thought this is not enough, the architectural change was for a good reason. I'll focus on closing all the issues raised in the 8.x-2.x upgrade for getting this fixed.

wendyl’s picture

Was this error resolved? I see where a patch was attempted to be developed and failed, but that was 2 months ago. Has there been a solution since then?

penyaskito’s picture

Status: Needs review » Closed (duplicate)

8.x-2.x was already released and it fixes this issue. You probably need to upgrade Lingotek first and then Drupal core.
Let us know if you need any help with this.

rahul patidar’s picture

Thanks #penyaskito. Updating lingotek does for me, saved a day.