Closed (duplicate)
Project:
Drupal core
Version:
9.1.x-dev
Component:
rdf.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2015 at 20:54 UTC
Updated:
21 Jul 2020 at 05:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
hass commentedComment #3
hass commentedComment #4
nplowman commentedThe problem seems to be related to "orphaned" comments, where the Comment entity still exists, but references an Entity that has been deleted.
In these cases, the call to $comment->getCommentedEntity() in rdf_comment_storage_load() returns null.
Here's a patch I created as a work-around for this issue, as it was causing issues with things like XML Sitemap.
This just places a guard to make sure that the entity is valid before attempting to get the URL.
Comment #5
hass commentedComment #7
klemendev commentedI can confirm that patch provided at #4 solved the issue for me. The issue occurred when I migrated comments from d7 website to d8.
But my case for reproduction is different. I created a view that counts comment number for the specific user and when the view is shown, the website returns error 500, but the cause for the error is the same.
Comment #8
ao2 commentedI saw this when running
drush migrate-rollback --allon drupal 8.4; the patch in #4 improves the situation but, at least here, it also happened that in some other case it's the parent comment entity to be null.The check on
$comment->hasParentComment()does not seem enough because even when this passes$comment->getParentComment()could still return null.I don't know the low level details, I am just reporting my observations.
Comment #9
ao2 commentedI see similar issues reported in #2793437: Fatal error: Call to a member function url() on a non-object in line number 243 rdf.module, #2558923: Comment migrations produce fatal errors when RDF module is enabled and #2863744: Comment Admin & Deleting Users with comments fails with error..
Comment #11
djg_tram commentedI don't have git and the related stuff installed now, so no patch, sorry, but the very simple and very obvious solution is to add this, too:
Comment #13
paranojik commentedJust posting patch based on #4 and #11.
Comment #15
paranojik commented..reposting
Comment #16
compugeekpro commentedparanojik,
I just wanted to confirm that patch #15 for the RDF module did work for me, but I also had to install patch #15 to the views/Plugin/field/BulkForm.php file found here: https://www.drupal.org/project/drupal/issues/2951493.
At first glance, it appears I had originally had stranded revision data.
Thank you for the patch! I'm fairly new to Drupal, but am hoping to help take care of some various issues as well and am able to provide patches every now and again if someone isn't setup to do so. Will keep a lookout in the forums. :)
Just FYI, I will likely post a comment in the other issue forum so people know it may be necessary to install both patches in their case until these updates are rolled into the core.
Comment #17
abrammI believe the root problem is incorrect getCommentedEntity() @return value doc; I've raised #3001851: Incorrect documented CommentInterface::getCommentedEntity() return value for this.
Comment #18
abrammThe following condition in #15 is incorrect:
The toUrl() method is provided by the \Drupal\Core\Entity\EntityInterface, not by \Drupal\Core\Entity\Entity.
Also, there's no more need to check $comment->hasParentComment() since the $parent value is checked in next line. Should be something like this:
Comment #19
abrammAlso, the return statement breaks processing multiple entities.
Comment #20
abrammComment #21
abrammHere we go. Fixed issues I found in #15.
Interdiff included.
Comment #23
ao2 commentedWhile not strictly forbidden by the coding standard, I'd avoid assignments in conditions.
In this case splitting the assignment would also follow the predominant style used in the rest of the file.
Ciao,
Antonio
Comment #24
abrammI don't think the assignment in condition is such a big deal. I've looked through the code and found 20 such assignments just in the comment module so it's a common practice.
I'm more worried by the test failure.
Comment #26
aswathyajish commented#15 worked for me. Thanks a lot.
Comment #27
Christopher Riley commented#21 nor #15 appear to work with 8.7.alpha2
Comment #28
vadim.hirbu commentedAdded a patch according latest updates.
I've not added an interdiff file while I wasn't able to make to apply any of old patches.
Comment #29
dmytro-aragornCouldn't apply the latest patch into 8.7. Adding a new patch according to latest updates in 8.7.x release.
Comment #30
scalas89 commentedAdding a new patch according to latest updates in 8.7.x release.
Comment #32
andypostComment #33
rollins commentedFailed to apply #29 into Drupal 8.7.5 release.
Adding a new patch according to updates in 8.7.5 release.
Comment #34
andypostit also needs a way to clean-up "orphans" probably in follow-up issue
PS: in D7 we detected orphan actions, maybe makes sense for comment as well in d8
Comment #36
klemendev commentedThis issue can still sometimes happen even with comments posted on D8 page, not on the comments migrated from D7 pages.
This bug essentially causes the websites with orphaned comments to not load.
Comment #38
steinmb commentedAlso experiencing it failing on migrate:rollaback
Call to a member function toUrl() on null in rdf_comment_storage_load() (line 245Confirm that If I uninstall RDF rollback works as expected.
Comment #43
pameeela commentedAdded #2793437: Fatal error: Call to a member function url() on a non-object in line number 243 rdf.module as a duplicate and will close that, so also added and aviral2809, Ruedische, jeetmail72, KlemenDEV, hchonov from that issue for credit.
Comment #44
serverjohn commentedJust a note. #4 was the only thing that worked for me on 8.8.*
Comment #46
pameeela commentedFound another duplicate in #2863744: Comment Admin & Deleting Users with comments fails with error. so closed that, adding as related and adding contributors.
Comment #47
mayurjadhav commentedAdded rerolled patch for 8.9.x & 9.1.x, Kindly review.
Comment #49
quietone commentedFollowing the steps in the IS I was unable to reproduce the error.
Reading the issue the majority of comments refer to getting this error after a migration of comments but KlemenDEV reports this can happen with comments posted on a D8 site, see #36.
I think this is a duplicate of #2614720: Fatal errors while loading/building orphaned comments. That issue includes a test and changes to the comment module to handle orphans as well as the changes to rdf.module that are included.
Comment #50
quietone commented@pameeela, thanks, seeing this in the BugSmash queu got me to take another look!
Thanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.
I'm closing this as a duplicate of #2614720: Fatal errors while loading/building orphaned comments and will move credit to that issue.
If anyone can provide information on why this issue is different, please add complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active".
Comment #51
pameeela commented