Problem/Motivation
1. d7_disqus_comment_status contains a dependency which isn't evaluated by the Migrate API: d7_node:*. It should be only d7_node.
2. Most of the Disqus migrations are missing the migration tags (Configuration and Content).
3. The Drupal 9 disqus field value lacks schema
Steps to reproduce
Proposed resolution
Since the d7_disqus_comment_status migration only updates already migrated nodes (and only their most recent default revision), the right solution is that this migration should be replaced with a plugin alter (which adds the process pipeline for the disqus field) and with a prepare hook (which adds the appropriate status and identifier field values). This also means that, we should add a deriver class for the d7_disqus_field migration, and make all node migrations depend on the corresponding d7_disqus_field derivative.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | migration_dependency_for_comment_status_3260107-22.patch | 410 bytes | anton4uk |
| #12 | migration_dependency_for_comment_status_3260107-12.patch | 10.66 KB | srishtiiee |
| #4 | migration_dependency_for_comment_status_3260107-4.patch | 11.17 KB | srishtiiee |
Comments
Comment #2
srishtiiee commentedComment #3
srishtiiee commentedComment #4
srishtiiee commentedComment #5
gaurav.kapoor commentedComment #6
gaurav.kapoor commentedWow. That's a good observation and a near-perfect way to fix things. Unfortunately, I don't have a very deep understanding of the migration framework and would like to see some more reviews for the patch which you have provided. Thanks for spending time on this.
Comment #7
gaurav.kapoor commented@srishti.bankar Thanks for providing schema though. I have taken it from your patch and pushed it with the commit for this issue https://www.drupal.org/project/disqus/issues/2289295.
You will have to slightly modify your patch to ensure it works with the latest development release. Thanks.
Comment #8
huzookaExcellent work!
The few nits we found:
This should be removed per #7
Please remove this empty func doc line.
Please replace these FQCNs with use statements!
While I was testing this patch, I noticed that we cannot assume that the source plugin is only available is the appropriate module (in this case:
disquswas enabled in the source Drupal instance.We have to check whether the source plugin's requirements are met, and if they aren't, then we shouldn't do anything:
You don't use these column values at all. What you're using is the evaluated SQL expression you add to this query.
You can simply remove this
SelectInterface::fields()call.and if you did the above, then you can simply call
$disqus_status = $query->execute()->fetchField();. I will be either1or'0'.I just noticed that this configuration doesn't do what I thought:
https://drupal.slack.com/archives/C226VLXBP/p1643200586343300
But then how can we prevent these migrations from being executed if the
disqusmodule isn't enabled on the source, but some why we have it installed on the destination site?..I see only one solution:
In your
migration_plugins_alterhook, you will check whether the requirements of thedisqus_enabled_content_typessource plugin are met. If it fails, then before your return statement, you have to manually remove thed7_disqus_settingsand thed7_disqus_field_storagemigrations:Comment #9
huzooka@srishti.bankar, @gaurav.kapoor, I want to attach the test infrastructure I'm using.
99% of this patch is a database fixture of a Drupal 7 instance, the actual test is about 8 kilobytes.
Comment #10
huzookaComment #11
huzookaUnfortunately, the patch I added in #9 contains the patch file itself as well.
Comment #12
srishtiiee commentedComment #13
gaurav.kapoor commentedComment #14
huzookaOnly three nits:
I just learned that calling static trait methods is deprecated in PHP 8.1.x, so we shouldn't do this anymore.
But since DisqusDeriver you're adding uses MigrationDeriverTrait, you can use that class to get the same source plugin instance:
Comment #15
srishtiiee commentedComment #16
huzooka👌All my previous concerns are addressed in #15.
I'm uploading a simplified test-only patch as well. (Simplified stands for that it does not require Migrate Magician anymore.)
Comment #17
gaurav.kapoor commented@srishti.bankar @huzooka Thanks for working on this. Regarding this,
This is assuming that the identifier will have a default value of type 'node:{node_id}', but the user can set the identifier value to any string. I am not sure if the D7 version has a feature of allowing users to change the identifier. In case there is an option, this will just set the wrong value for the identifier.
Rest everything looks good to me.
Comment #18
huzookaRe #17:
Now it does the same what the previous (standalone) status migration's source plugin did, so we won't add any regressions.
I ask you to allow us address this in a follow-up issue (but we will need some pointers).
Comment #20
gaurav.kapoor commentedThanks, @huzooka. I quickly scanned the D7 codebase and it turns out there is no option to set a value for identifier and it is always 'node:nid'. Pushing this to 2.0.x.
Cheers!!
Comment #22
anton4uk commentedI've got a fatal error on
drush ms"The "disqus_enabled_content_types" plugin does not exist."I am attaching a temporary solution.