Comments

hass created an issue. See original summary.

hass’s picture

Issue summary: View changes
hass’s picture

Issue summary: View changes
nplowman’s picture

StatusFileSize
new788 bytes

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

hass’s picture

Version: 8.0.0-beta15 » 8.4.x-dev
Status: Active » Needs review

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

klemendev’s picture

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

ao2’s picture

I saw this when running drush migrate-rollback --all on 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.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

djg_tram’s picture

I 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:

    if ($comment->hasParentComment()) {
      $parent = $comment->getParentComment();
      if ($parent) {
        $comment->rdf_data['pid_uri'] = $parent->url();
      }
    }

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

paranojik’s picture

StatusFileSize
new1.02 KB

Just posting patch based on #4 and #11.

Status: Needs review » Needs work

The last submitted patch, 13: member-function-url-fix-2565247-13.patch, failed testing. View results

paranojik’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

..reposting

compugeekpro’s picture

paranojik,

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.

abramm’s picture

I believe the root problem is incorrect getCommentedEntity() @return value doc; I've raised #3001851: Incorrect documented CommentInterface::getCommentedEntity() return value for this.

abramm’s picture

The following condition in #15 is incorrect:

if (!$entity instanceof \Drupal\Core\Entity\Entity) {
...
}

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->rdf_data['entity_uri'] = $entity->toUrl()->toString(TRUE)->getGeneratedUrl();
    if ($parent = $comment->getParentComment()) {
      $comment->rdf_data['pid_uri'] = $parent->toUrl();
    }
abramm’s picture

Also, the return statement breaks processing multiple entities.

abramm’s picture

Status: Needs review » Needs work
abramm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.73 KB
new1.77 KB

Here we go. Fixed issues I found in #15.

Interdiff included.

Status: Needs review » Needs work

The last submitted patch, 21: interdiff-15-21.patch, failed testing. View results

ao2’s picture

...
+      if ($parent = $comment->getParentComment()) {
+        $comment->rdf_data['pid_uri'] = $parent->toUrl();
+      }

While 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

abramm’s picture

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

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aswathyajish’s picture

#15 worked for me. Thanks a lot.

Christopher Riley’s picture

#21 nor #15 appear to work with 8.7.alpha2

vadim.hirbu’s picture

Status: Needs work » Needs review
StatusFileSize
new1.75 KB

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

dmytro-aragorn’s picture

Couldn't apply the latest patch into 8.7. Adding a new patch according to latest updates in 8.7.x release.

scalas89’s picture

Adding a new patch according to latest updates in 8.7.x release.

Status: Needs review » Needs work
andypost’s picture

Issue tags: +Needs tests
rollins’s picture

StatusFileSize
new1.76 KB

Failed to apply #29 into Drupal 8.7.5 release.
Adding a new patch according to updates in 8.7.5 release.

andypost’s picture

Issue tags: +Needs upgrade path

it 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

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

klemendev’s picture

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

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

steinmb’s picture

Also experiencing it failing on migrate:rollaback
Call to a member function toUrl() on null in rdf_comment_storage_load() (line 245

Confirm that If I uninstall RDF rollback works as expected.

pameeela credited hchonov.

pameeela’s picture

Added #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.

serverjohn’s picture

Just a note. #4 was the only thing that worked for me on 8.8.*

pameeela credited Rewted.

pameeela’s picture

Found another duplicate in #2863744: Comment Admin & Deleting Users with comments fails with error. so closed that, adding as related and adding contributors.

mayurjadhav’s picture

Status: Needs work » Needs review
StatusFileSize
new1.52 KB

Added rerolled patch for 8.9.x & 9.1.x, Kindly review.

Status: Needs review » Needs work

The last submitted patch, 47: rdf_comment_storage_load-2565247-47.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#2614720: Fatal errors while loading/building orphaned comments

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

quietone’s picture

Status: Needs review » Closed (duplicate)

@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".

pameeela’s picture

Issue tags: +Bug Smash Initiative