On migrating a D6 test site, content generated by devel, I get Fatal errors from d6_comment. Previously, this site was migrating, except for files, successfully.

Importing d6_comment
PHP Fatal error:  Call to a member function url() on a non-object in /opt/sites/md82/core/modules/rdf/rdf.module on line 237
PHP Stack trace:
PHP   1. {main}() /usr/local/share/drush/drush.php:0
PHP   2. drush_main() /usr/local/share/drush/drush.php:11
PHP   3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /usr/local/share/drush/drush.php:70
PHP   4. drush_dispatch() /usr/local/share/drush/lib/Drush/Boot/BaseBoot.php:62
PHP   5. call_user_func_array:{/usr/local/share/drush/includes/command.inc:178}() /usr/local/share/drush/includes/command.inc:178
PHP   6. drush_command() /usr/local/share/drush/includes/command.inc:178
PHP   7. _drush_invoke_hooks() /usr/local/share/drush/includes/command.inc:210
PHP   8. call_user_func_array:{/usr/local/share/drush/includes/command.inc:359}() /usr/local/share/drush/includes/command.inc:359
PHP   9. drush_migrate_upgrade() /usr/local/share/drush/includes/command.inc:359
PHP  10. Drupal\migrate_upgrade\MigrateUpgradeDrushRunner->import() /opt/sites/md82/modules/migrate_upgrade/migrate_upgrade.drush.inc:42
PHP  11. drush_op() /opt/sites/md82/modules/migrate_upgrade/src/MigrateUpgradeDrushRunner.php:50
PHP  12. drush_call_user_func_array() /usr/local/share/drush/includes/drush.inc:705
PHP  13. call_user_func_array:{/usr/local/share/drush/includes/drush.inc:714}() /usr/local/share/drush/includes/drush.inc:714
PHP  14. Drupal\migrate\MigrateExecutable->import() /usr/local/share/drush/includes/drush.inc:714
PHP  15. Drupal\comment\Plugin\migrate\destination\EntityComment->import() /opt/sites/md82/core/modules/migrate/src/MigrateExecutable.php:266
PHP  16. Drupal\migrate\Plugin\migrate\destination\EntityContentBase->import() /opt/sites/md82/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php:81
PHP  17. Drupal\migrate\Plugin\migrate\destination\Entity->getEntity() /opt/sites/md82/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php:76
PHP  18. Drupal\Core\Entity\EntityStorageBase->load() /opt/sites/md82/core/modules/migrate/src/Plugin/migrate/destination/Entity.php:112
PHP  19. Drupal\Core\Entity\EntityStorageBase->loadMultiple() /opt/sites/md82/core/lib/Drupal/Core/Entity/EntityStorageBase.php:217
PHP  20. Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple() /opt/sites/md82/core/lib/Drupal/Core/Entity/EntityStorageBase.php:247
PHP  21. Drupal\Core\Entity\ContentEntityStorageBase->invokeStorageLoadHook() /opt/sites/md82/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:401
PHP  22. rdf_comment_storage_load() /opt/sites/md82/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:360

Fatal error: Call to a member function url() on a non-object in /opt/sites/md82/core/modules/rdf/rdf.module on line 237
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

mikeryan’s picture

Title: d6_comment Fatal error » d6_comment Fatal error when RDF module is enabled
phenaproxima’s picture

Title: d6_comment Fatal error when RDF module is enabled » Comment migrations produce fatal errors when RDF module is enabled

After a few solid hours of debugging, I have figured out the incredibly sneaky and insidious cause of this fatal. Give me a freaking medal! :)

While importing a comment:

  1. The migration process plugin tries to look up the comment's pid. If it cannot be found, it creates and saves a stub comment. That stub has a specific ID (the pid which could not be found), but little else. Crucially, it does not have an entity that "owns" it (i.e., the entity that was commented upon) -- its entity_id field is NULL.
  2. At some further point in the migration, the comment which was stubbed is being imported for real. The Entity destination's getEntity() method is called, which results in the comment storage's load() method being called (because Entity is trying to ascertain if the comment already exists or needs to be created).
  3. The comment storage handler queries the database for the comment, and finds it -- because it was stubbed back in step 1.
  4. The comment storage handler invokes hook_comment_storage_load() on the comments loaded from the DB. RDF, which implements this hook, innocently calls $comment->getCommentedEntity() on the loaded stub -- which, you'll remember, does not refer to an entity. Because it was a stub. So getCommentedEntity() returns NULL.
  5. rdf_comment_storage_load() tries to call methods of the commented entity and fatals because the commented entity is NULL.
phenaproxima’s picture

With tests, and my compliments!

There's a bit of patch noise in the passing patch because I removed a few deprecated function calls from MigrateCommentTest.

neclimdul’s picture

vancode strikes again!

The last submitted patch, 4: 2558923-4-FAIL.patch, failed testing.

phenaproxima’s picture

Priority: Normal » Major
Issue tags: +Migrate D7 critical

Escalating. This will cause failures on any site with a substantial number of comments if the D8 RDF module is enabled -- which, in the default install profile, it is. So this is likely to be encountered by a lot of people.

phenaproxima’s picture

Whoops. This affects D6 and D7.

The last submitted patch, 4: 2558923-4-FAIL.patch, failed testing.

benjy’s picture

phenaproxima’s picture

This patch doesn't change the stubbing at all -- it works around the problem by introducing better ordering into the comment sources. I think we should commit this now and continue work on that patch, since:

  • This patch is ready now;
  • It doesn't change or affect the stubbing code in any way;
  • It will prevent fatal errors for people migrating even a modest amount of comments

The other patch is good and work should continue on it; when it lands it will reinforce this one.

benjy’s picture

This patch is more of a workaround where as the other patch fixes the root cause of the problem. Some people might import comments from a CSV where they can't change the order in the source for example.

And I think the comments in this patch that mention ordering to avoid fatals are a bit weird because i'd read those and think, hmm, that's the wrong fix.

However, if this issue helps the upgrade path fine, but I think the comments in the patch should be re-done to reference the issue with the "correct" fix and mention that the order is a temporary work around.

phenaproxima’s picture

Status: Needs review » Needs work
Related issues: +#2340401: Fill commented entity during stub comment saving

That seems like an exceedingly fair compromise to me. If you're OK with the workaround as it is, I'll reroll the patch tomorrow, fix the comments, and get it committed.

benjy’s picture

Yeah that's good for me.

neclimdul’s picture

why not both? :)

phenaproxima’s picture

Status: Needs work » Needs review
FileSize
4.61 KB
1.82 KB

Comments fixed.

quietone’s picture

Applied this patch but I'm still getting a Fatal.

Importing d6_comment
PHP Fatal error:  Call to a member function url() on a non-object in /opt/sites/md8/core/modules/rdf/rdf.module on line 237
PHP Stack trace:
PHP   1. {main}() /usr/local/share/drush/drush.php:0
PHP   2. drush_main() /usr/local/share/drush/drush.php:11
PHP   3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /usr/local/share/drush/drush.php:70
PHP   4. drush_dispatch() /usr/local/share/drush/lib/Drush/Boot/BaseBoot.php:62
PHP   5. call_user_func_array:{/usr/local/share/drush/includes/command.inc:183}() /usr/local/share/drush/includes/command.inc:183
PHP   6. drush_command() /usr/local/share/drush/includes/command.inc:183
PHP   7. _drush_invoke_hooks() /usr/local/share/drush/includes/command.inc:215
PHP   8. call_user_func_array:{/usr/local/share/drush/includes/command.inc:364}() /usr/local/share/drush/includes/command.inc:364
PHP   9. drush_migrate_upgrade() /usr/local/share/drush/includes/command.inc:364
PHP  10. Drupal\migrate_upgrade\MigrateUpgradeDrushRunner->import() /opt/sites/md8/modules/migrate_upgrade/migrate_upgrade.drush.inc:42
PHP  11. drush_op() /opt/sites/md8/modules/migrate_upgrade/src/MigrateUpgradeDrushRunner.php:50
PHP  12. drush_call_user_func_array() /usr/local/share/drush/includes/drush.inc:705
PHP  13. call_user_func_array:{/usr/local/share/drush/includes/drush.inc:714}() /usr/local/share/drush/includes/drush.inc:714
PHP  14. Drupal\migrate\MigrateExecutable->import() /usr/local/share/drush/includes/drush.inc:714
PHP  15. Drupal\migrate\MigrateExecutable->processRow() /opt/sites/md8/core/modules/migrate/src/MigrateExecutable.php:255
PHP  16. Drupal\migrate\Plugin\migrate\process\Migration->transform() /opt/sites/md8/core/modules/migrate/src/MigrateExecutable.php:364
PHP  17. Drupal\comment\Plugin\migrate\destination\EntityComment->import() /opt/sites/md8/core/modules/migrate/src/Plugin/migrate/process/Migration.php:131
PHP  18. Drupal\migrate\Plugin\migrate\destination\EntityContentBase->import() /opt/sites/md8/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php:81
PHP  19. Drupal\migrate\Plugin\migrate\destination\Entity->getEntity() /opt/sites/md8/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php:76
PHP  20. Drupal\Core\Entity\EntityStorageBase->load() /opt/sites/md8/core/modules/migrate/src/Plugin/migrate/destination/Entity.php:112
PHP  21. Drupal\Core\Entity\EntityStorageBase->loadMultiple() /opt/sites/md8/core/lib/Drupal/Core/Entity/EntityStorageBase.php:217
PHP  22. Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple() /opt/sites/md8/core/lib/Drupal/Core/Entity/EntityStorageBase.php:247
PHP  23. Drupal\Core\Entity\ContentEntityStorageBase->invokeStorageLoadHook() /opt/sites/md8/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:401
PHP  24. rdf_comment_storage_load() /opt/sites/md8/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:360
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                      [error]
Error: Call to a member function url() on a non-object in /opt/sites/md8/core/modules/rdf/rdf.module, line 237
phenaproxima’s picture

Status: Needs review » Closed (won't fix)

@mikeryan says he's close to getting #2340401: Fill commented entity during stub comment saving completed, so I think it makes sense to close this and pursue that patch full-throttle.

deepeshvishwa’s picture

Hello,

I got this error in Drupal 8.2.5 and I have fixed it. :)

Please see the details as below:
Issue: If comment created date is zero then fatal error come.
Solution: I have added any date in "created" column in "comment_field_data" in database using query and clear the cache. like that:

SELECT * FROM comment_field_data WHERE created = 0
UPDATE comment_field_data SET created = 1222056000, changed = 1222056000 WHERE cid = 7277;

I have used SQL because I have to perform for bulk records, you can try with edit comment.

If any query, please let me know.

Thanks,
Deepesh