Can't preview new nodes

Created on 22 November 2023, 7 months ago
Updated 18 January 2024, 5 months ago

Problem/Motivation

When I try to preview a new node and I have the "AddToAny share buttons" block on the content region, I get the error below because the node I'm trying to preview does not have a node id yet. A similar issue had been reported and fixed recently on https://www.drupal.org/project/addtoany/issues/3372598; β†’ however, once https://www.drupal.org/project/addtoany/issues/3138220 πŸ› No link template 'canonical' found for the 'paragraph' entity type Fixed was merged, the issue was reintroduced.

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).

Steps to reproduce

- Add "AddToAny share buttons" block to main content region.
- Create a new node, and try to preview the node before saving.
- You should see an error message above.

Proposed resolution

- Check if the entity being previewed is a new entity before calling $entity->toUrl() on addtoany_create_entity_data().

Remaining tasks

- Create a patch.

User interface changes

- None.

API changes

- None.

Data model changes

- None.

πŸ› Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mmenavas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024