Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293850

Migration for forum and article comments: duplicate comment types and incorrect comment_entity_statistics

$
0
0

Problem/Motivation

I migrated my D7 site to 8.4.x-dev. When migrating forum content, I noticed that the Replies and Last reply columns of the forum thread list view are not taking the migrated comments into account.

Please see the attached screenshot: d8-forum-migrate.PNG

  • The first thread in the screenshot has actually 32 migrated comments and 1 comment added in D8. The view is showing that the thread would only have 1 comment instead of 33. This one comment is the one added in D8.
  • The second thread has only 1 comment which was added in D8. This comment is shown correctly in the comment count.
  • The third thread is created in D8 and it has 1 comment which was added in D8. This comment is shown correctly in the comment count.
  • All other threads are migrated ones and they all have comments but the Replies and Last reply columns are not showing them.
  • The comments can be seen if you drill into the thread.
  • The issue persists even if I clear all caches.

The root cause for this bug is that the database table comment_entity_statistics is populated incorrectly when migrating comments.

  • Drupal 8 forum reads the comment statistics from database table comment_entity_statistics with field_name comment_forum. See comments #4 and #5 for more details.
  • The migrate process currently creates an incorrect entry to this table with field_name comment_node_forum
  • See attached screesnshot on how the entries look like: comment_entity_statistics.PNG

When investigating further, this same bug has also another symptom. The built-in content types Article and Forum have two comment types after migration:

  • See attached screenshot from article field settings: 2853872-duplicate-comment-types-article.png
  • Vanilla D8 article content type already has a comment type comment but the D7-D8 migration adds also comment type comment_node_article. As a result, the content type has now two commen types. When comments are migrated, the comment_entity_statistics table gets incorrectly populated.
  • See attached screenshot from forum field settings: 2853872-duplicate-comment-types-forum.png
  • Vanilla D8 forum content type already has a comment type comment_forum but the D7-D8 migration adds also comment type comment_node_forum. As a result, the content type has now two commen types. When comments are migrated, the comment_entity_statistics table gets incorrectly populated as illustrated above in the earlier screenshot.

Proposed resolution

  • Do not create comment types comment_node_forum and comment_node_article for forum and article content types because these content types already have the out of the box comment fields. Several comment / field migrations need to be updated.
  • Introduce a new process plugin skip_row_if_in_blacklist which allows us to skip comment_node_forum and comment_node_article rows in these migrations.
  • Use static_map process plugin to map the D7 comment / field migrations to the D8 standard comment_forum and comment comment types
  • Remark: the third standard D8 content type Page does not have any comment fields by default so that is not suffering from this issue. No actions required for Page content type.

Remaining tasks

1. Review patch.
2. Evaluate if this same bug applies to D6-D8 migration as well.

User interface changes

None.

API changes

None.

Data model changes

None.


Viewing all articles
Browse latest Browse all 293850

Trending Articles