Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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_display
d6_comment_entity_form_display
d6_comment_entity_form_display_subject
d6_comment_field
d6_comment_field_instance
d6_comment_type
Drupal 7:
d7_comment_entity_display
d7_comment_entity_form_display
d7_comment_entity_form_display_subject
d7_comment_field
d7_comment_field_instance
d7_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_type
andd6_node_type
. This source plugin has toextendcopy the correspondingd[6|9]_node_type
migration source plugin, but it should definecomment
as 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: comment
to 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
,node
or 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\CommentTypeTest
verifies the basic functionality.\Drupal\Tests\comment\Kernel\Plugin\migrate\source\CommentTypeRequirementsTest
tests the expected\Drupal\migrate\Exception\RequirementsException
Comment #7
Wim LeersTested in detail, works great!
Comment #8
quietone CreditAttribution: quietone as a volunteer 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 CreditAttribution: quietone as a volunteer 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.