- Issue created by @RhiP
- Open on Drupal.org →Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - @rhip opened merge request.
Some site editor user journeys result in this error:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '21-300' for key 'PRIMARY': INSERT INTO "decision_content_usage" ("parent_entity_type", "parent_entity_id", "parent_entity_vid", "decision_entity_id", "decision_entity_vid") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => paragraph [:db_insert_placeholder_1] => 224567 [:db_insert_placeholder_2] => 653835 [:db_insert_placeholder_3] => 21 [:db_insert_placeholder_4] => 300 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\Core\Database\StatementWrapper->execute(Array, Array) (Line: 44)
Drupal\mysql\Driver\Database\mysql\Insert->execute() (Line: 110)
Drupal\smart_content\Plugin\smart_content\Decision\Storage\ContentEntity->addUsage(Object) (Line: 175)
Drupal\smart_content_block\BlockFieldEntityOperations->handleUpdate(Object) (Line: 61)
smart_content_block_entity_update(Object) (Line: 76)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler::Drupal\hook_event_dispatcher\{closure}(Object, 'smart_content_block') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object) (Line: 91)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler->invokeAllWith('entity_update', Object) (Line: 83)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler->invokeAll('entity_update', Array) (Line: 251)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 598)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 523)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 303)
Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->preSave() (Line: 233)
Drupal\Core\Field\FieldItemList->delegateMethod('preSave') (Line: 191)
Drupal\Core\Field\FieldItemList->preSave() (Line: 938)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 888)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 563)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 517)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 270)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('node_homepage_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 37)
Drupal\cft_personalisation\AnonSessionMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 187)
Drupal\cleantalk\EventSubscriber\BootSubscriber->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Example of steps that produce the error on our local site (not a clean vanilla site):
1. Edit a node that uses Smart Content
2. Add a smart content paragraph and decision block
3. Add a segment
4. Do not add a reaction
5. Save the node
Patch to follow.
Active
3.1
Code