Fatal error after saving the page not have a reuse entity
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: The "" entity type does not exist. in <em class="placeholder">Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()</em> (line <em class="placeholder">847</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php</em>). <pre class="backtrace">Drupal\Core\Entity\EntityRepository->loadEntityByUuid('', '') (Line: 31)
Drupal\entity_usage\Plugin\EntityUsage\Track\TextFieldEmbedBase->getTargetEntities(Object) (Line: 148)
Drupal\entity_usage\EntityUsageTrackBase->trackOnEntityCreation(Object) (Line: 171)
Drupal\entity_usage\EntityUsageTrackBase->trackOnEntityUpdate(Object) (Line: 107)
Drupal\entity_usage\EntityUpdateManager->trackUpdateOnEdition(Object) (Line: 41)
entity_usage_entity_update(Object)
call_user_func_array('entity_usage_entity_update', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 206)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 835)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 535)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 720)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 460)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase->save() (Line: 285)
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: 873)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 823)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 500)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 692)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 454)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase->save() (Line: 285)
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: 873)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 823)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 500)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 692)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 454)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase->save() (Line: 294)
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: 590)
Drupal\Core\Form\FormBuilder->processForm('node_landing_page_edit_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
</pre>
Comments
Comment #2
firass.ziedanComment #3
firass.ziedanComment #4
firass.ziedanComment #5
marcoscanoThanks for reporting this and for the patch.
Looking at the stack trace, it looks like there may be some broken markup that's causing the parser to break? Could you please provide more details about the setup you used to reproduce this issue? That would help us nail down exactly what made the system fail.
I agree the module shouldn't choke on bad content, but IMHO the fix should be in the plugins themselves, as part of the
::parseEntitiesFromText()method.Also, it would be great to have a test that covers this scenario as well.
Thanks!
Comment #6
gngn commentedI recently added entity_usage to a long running site and encountered a similiar error saving nodes:
I noticed empty
data-entity-uuidanddata-entity-typeattributes.I agree with @marcoscano in #5 that
::parseEntitiesFromText()is the best place to check for this.I only encountered the error with Plugin\EntityUsage\Track\LinkIt and created a patch for that.
Plugin\EntityUsage\Track\EntityEmbed is very similar so I expanded the patch to that one.
I am not quite sure what to do with the other Track Plugins.
So the attached patch only handles Track\LinkIt and Track\EntityEmbed.
Comment #7
Oscaner commentedWe cannot handle all Track plugin, because they are unknown, how much, how do.
So i think should focus on base code to fix it.
Comment #10
richardbporter commentedPatch in #6 works. I'm not sure the HtmlLink plugin needs this change because its getting the entity type and ID from the route, if it is routed. I added some logic to MediaEmbed combined with the patch in #6 to a new MR. I can attempt to write tests if this approach is ok.
Comment #12
richardbporter commentedComment #13
richardbporter commentedUploaded patch and interdiff from #6.
Comment #14
drupal-son commentedI have the same error and can confirm patch #6 is working.
In my case, there is something adding markup like this with empty attributes making the parser break up after saving.
<a class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://something.com" id="" rel="" target="_blank" title="">If removing the empty attributes, the node gets saved.
When using the patch and keeping the original empty attributes it worked too!
Comment #15
john cook commentedI can confirm that patch #13 fixes the issue; at least with the LinkIt plugin.
Changing to RTBC.
Comment #16
richardbporter commentedThe test failures after rebasing seem to be unrelated and are currently happening in 8.x-2.x-dev: https://www.drupal.org/pift-ci-job/2354527
Comment #17
baluertlComment #18
dasginganinjaI also ran into this issue today and tried patch #13.
It stumbled upon the CKEditor image plugin so I added support for that in.
I'm not sure if this needs additional tests, but it's not RTBC anymore :)
Comment #20
marcoscanoLooks good to me, thanks everyone who contributed!
Committed and tagged a new release with the fix in.