Method call toUrl() fails when previewing node resulting in following thrown error:

Drupal\Core\Entity\EntityMalformedException: The "node" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\Entity->toUrl()

patch attached

Comments

bletch created an issue. See original summary.

bletch’s picture

StatusFileSize
new818 bytes
naveenvalecha’s picture

Version: 8.x-2.0-beta2 » 8.x-2.x-dev
naveenvalecha’s picture

Status: Active » Needs review

Checking what test bot feels with changes

Status: Needs review » Needs work

The last submitted patch, 2: sharethis-previewfix-2706325-1-8.x.patch, failed testing.

naveenvalecha’s picture

we have remove the toUrl method and now relied on the \Drupal::request to provide the current request uri
Could you re test the 8.x-2.x

navneet0693’s picture

Status: Needs work » Closed (cannot reproduce)

Not able to produce this issue. Attaching screenshot.

ShareThis: 8.x-2.x-dev
Drupal : 8.1.1

lokeshsn22’s picture

Got the same issue as mentioned above. @naveenvalecha , can you please update the share this module with the patch. I just removed toUrl method and update with the \Drupal::request to provide the current request Uri . It worked.

Thanks,
Lokesh.S

naveenvalecha’s picture

Status: Closed (cannot reproduce) » Active
lokeshsn22’s picture

StatusFileSize
new33.19 KB
Sonal.Sangale’s picture

Assigned: Unassigned » Sonal.Sangale
Sonal.Sangale’s picture

Assigned: Sonal.Sangale » Unassigned
Status: Active » Needs review
StatusFileSize
new776 bytes

Adding patch according to suggestion #8.

Please review.

gg24’s picture

Status: Needs review » Reviewed & tested by the community

This patch brings back the expected services. Patch works as intended.

navneet0693’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/sharethis.module
@@ -93,8 +93,9 @@ function sharethis_node_view(array &$build, EntityInterface $node, EntityViewDis
+  // Method toUrl in Node object has been deprecated in D8. Used request object

I think we don't need this comment in module file. We can retain with previous comment.

gg24’s picture

Assigned: Unassigned » gg24
gg24’s picture

Assigned: gg24 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new580 bytes
navneet0693’s picture

Status: Needs review » Reviewed & tested by the community

@naveenvalecha your call now ;)

benjifisher’s picture

I think this is a duplicate of #2767165: Node Preview functionality break before node save (although this issue was created first). Both issues are marked RTBC. I like the patch on that issue better, but I am not sure enough to close this one as a duplicate.

leon kessler’s picture

Status: Reviewed & tested by the community » Needs work

Agree with @benjifisher, patch on the other issue is better. Patch #16 will break if the current page isn't that of the node (e.g. you are viewing the node teaser). I think probably one should be marked as a duplicate.

greg boggs’s picture

Status: Needs work » Closed (duplicate)