Problem/Motivation
If one migrates data from a Drupal 7 source that does not have comment module enabled, but the destination site does have comment module enabled, every comment related migrations (which are using the d7_node_type source plugin) will be executed producing e.g. comment types for every node type in the source.
Affected migration plugins:
Drupal 6:
d6_comment_entity_displayd6_comment_entity_form_displayd6_comment_entity_form_display_subjectd6_comment_fieldd6_comment_field_instanced6_comment_type
Drupal 7:
d7_comment_entity_displayd7_comment_entity_form_displayd7_comment_entity_form_display_subjectd7_comment_fieldd7_comment_field_instanced7_comment_type
Proposed resolution
Do not migrate comment bundles when the comment module is disabled on the source Drupal 7 instance.
- Solution A: add a new migration sources for comment configuration migrations that replaces
d7_node_typeandd6_node_type. This source plugin has toextendcopy the correspondingd[6|9]_node_typemigration source plugin, but it should definecommentas its source module. Solution B (if #3176393: Use SourcePluginBase::getSourceModule() in DrupalSqlBase::checkRequirements() can be committed): add aThis isn't enough since comment type migrations require both comment and node modules.source_module: commentto the migrations listed above.
Comments
Comment #2
huzookaComment #3
huzookaComment #4
huzookaAdded a test-only patch for comment type (comment "bundle") migration tests to verify that no comment types are migrated when
comment,nodeor both of them are disabled on the source.The new "complete" patch adds additional test coverage for the new
CommentType(comment_type) migration source plugin.\Drupal\Tests\comment\Kernel\Plugin\migrate\source\CommentTypeTestverifies the basic functionality.\Drupal\Tests\comment\Kernel\Plugin\migrate\source\CommentTypeRequirementsTesttests the expected\Drupal\migrate\Exception\RequirementsExceptionComment #7
wim leersTested in detail, works great!
Comment #8
quietone commentedYes, the test coverage certainly looks thorough!
The two items I found are in the d6/d7 MigrateCommentTypeTests.
When the source fixture needs to be changed in a Migrate test the MigrateDumpAlterInterface is used for that. That would mean that this new test would move to a separate file. I am on the fence about this. It seems extra work for little gain.
According to the data provider this also tests with node and comment disabled but this summary suggests, to me, that it is either one or the other that is disabled. Maybe just make the summary line generic, "Tests comment type migration".
I'm setting to NW and feel free to push back on the first point.
Comment #9
huzookaComment #10
huzookaRe #8:
MigrateDumpAlterInterface::migrateDumpAlter()but also explains why it isn't used in this case.Comment #11
wim leersComment #13
catchCommitted 20895bd and pushed to 9.2.x. Thanks!
I think this should also go into 9.1.x - while it adds a class, it's fixing a bug and we generally err on the side of backporting migration fixes especially since we're still in the rc phase, but leaving at 'to be ported' in case we need to discuss more.
Comment #14
wim leers+1
Comment #15
wim leersSorry for not following through sooner here 😬
The patch in #10 in fact applies cleanly to
9.1.x— and still does today. Queuing tests to prove this…Comment #16
catchComment #17
huzookaComment #18
huzookaLet's see (first with SQLite)!
Comment #19
huzookaWith SQLite #18 works as it should – let's see othere nvs...
Comment #21
huzookaFailure of env PHP 7.3 & MySQL 5.7 seems to be unrelated (and I think I have already seen that before).
https://www.drupal.org/pift-ci-job/1958716
Comment #22
huzookaComment #23
quietone commentedI made a diff of the patches in #10 and #18 and confirmed that the reroll is fine. Patch still applies.
Comment #24
alexpottWe need a change record here to announce the new source migration plugin.
Comment #25
wim leersCR created: https://www.drupal.org/node/3197281
Comment #26
alexpottLet's get this into 9.1.x - in #24 I didn't realise that we'd already added to 9.2.x and this was only open for 9.1.x backport. I agree that since this is an addition, that fixes a bug, it is safe to backport.