On D9.01
When a new node is created and previewed before having been saved this error pops up. It's looking for an entity that doesn't exist yet (no node for addToany to use yet.
The website encountered an unexpected error. Please try again later.
Drupal\Core\Entity\EntityMalformedException: The "node" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\EntityBase->toUrl() (line 161 of core/lib/Drupal/Core/Entity/EntityBase.php).
addtoany_create_entity_data(Object) (Line: 95)
addtoany_entity_view(Array, Object, Object, 'full')
call_user_func_array('addtoany_entity_view', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_view', Array) (Line: 289)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 78)
Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 50)
Drupal\ban\BanMiddleware->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: 705)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)A workaround I did was to save the node in an unpublished status before previewing.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | error-on-preview-of-an-unsaved-new-node-3158968-2.patch | 573 bytes | ramya balasubramanian |
Comments
Comment #2
ramya balasubramanian commentedHi @cestmoi,
I have tried this issue and added a patch below. Please have a look.
Comment #3
cestmoi commentedThanks @Ramya Balasubramanian, sorry for the delay.
unfortunately it is still the same after applying the patch !It's working yes.
Comment #4
cestmoi commentedpatch #2 fixed it. thanks
Comment #5
micropat commentedThanks for reporting @cestmoi and for the patch Ramya. We plan to commit this patch later so it gets fixed in the next release.
Comment #6
dhendriks commentedWhen I create a node, set the mandatory fields, click the button to preview, I see an error. With this patch the same steps no longer lead to an error. The patch looks good to me.
I'm using Drupal 9.1.5 and AddToAny 8.x-1.14.
I noticed AddToAny 8.x-1.14 was released on 15 May 2020. When will there be a next release? Will this fix be included?
Comment #8
micropat commentedThanks for the report, the patch, and the reminder! Yes, this will make the next release soon.