Problem/Motivation
Several process plugins contain lookups against hardcoded migration ids. These ids can change in contrib, or custom migrations with different ids should be able to work with the process plugins.
A scenario where this is a problem is exampled in issue summary of the duplicate.
Process plugins:
[x] BlockPluginId.php used in d6_block.yml and d7_block.
[X] BlockVisibility.php used in d6_block.yml and d7_block.
[x] d7/FieldBundle.php used in d7_field_instance.yml
[X] d6/FieldFile.php OK. This is added to the migration by defineValueProcessPipeline so it is installed in the yaml as a process.
[X] d6/FilterFormatPermission.php used in d6_user_role.yml
[(x)] MenuLinkParent.php does a self lookup, so no change needed
Furthermore there are migrateLookup->lookup() calls in
- MigrateLookupTest
- MigrateStubTest
- MenuLinkParentTest
- MigrationLookupTest
unsure if these also have to be adjusted.
Proposed resolution
Move migration_lookups from the following plugin to the migration yml so that migrate_upgrade can find it.
- BlockPluginId.php
- BlockVisibility.php
- d7/FieldBundle.php
- d6/FilterFormatPermission.php
Add new process plugins to do the lookups given the migration ID supplied by the yml.
- block/src/Plugin/migrate/process/RolesLookup.php
- user/src/Plugin/migrate/process/d6/FilterFormatLookup.php
Remaining tasks
Review
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3091841
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
quietone commentedI've closed #220449: drupal.org, no confirmation page for new user as a duplicate of this.
The Issue Summary over there gives a really clear example of the problems this causes. Adding credit for the useful issue summary.
Comment #7
quietone commentedClosed #3231983: Allow custom migration id config for d6_field_file process plugin as a duplicate. Adding credit'
The proposed resolution from the duplicate was, 'Default the plugin to use the d6_file migration, but allow a config option in the migration yml file when employing the d6_field_file process plugin.'
Comment #8
anybodyCreated a POC of a DIRTY workaround for those of us who need an immediate solution until this is cleanly fixed. Marked it as WIP and named the branch "DIRTY" as it should never be committed.
https://git.drupalcode.org/project/drupal/-/merge_requests/1384.diff
@quietone, please don't kill me, I know this is very dirty and we need a conceptual solution.
Comment #10
quietone commented@Anybody, no worries. It is not ideal to have such a hack but some people may need it and I would rather they be able to be productive than stuck.
Comment #11
quietone commentedThis pulls out the migration_lookup from the BlockPluginId.php process plugin and places it in the migration yml where migrate-upgrade will find it.
Comment #13
danflanagan8The patch in #11 looks like a good start!
But we probably don't need to lookup against d6 and d7 migrations.
d6_blockshould lookup againstd6_custom_blockandd7_blockshould lookup againstd7_custom_block.Comment #14
quietone commentedIn a migrate meeting mikelutz was concerned about BC.
And yes, this will fail for anyone with a legacy generated yml.
Comment #15
quietone commentedThis offers a way to be BC and fixes the point in #13.
Comment #16
quietone commentedUpdate list of process plugins.
Comment #17
quietone commentedFix the coding standard error and add changes for FieldBundle.php
Comment #18
quietone commentedThe remaining two are not as easy because the lookups are in for loops.
Comment #19
danflanagan8Do you have an idea of how you would approach it?
Ah yes. Looks like you have addressed that nicely now!
Here's are my comments on the latest patch.
1. It doesn't look like this constant is used.
2. What would you think about changing the code below such that we don't define
_comment_type_source?It could be changed to this I think, which looks clearer to me.
Comment #21
quietone commentedClosed #3063273: BlockPluginId process plugin hard codes migrations breaking migrate_upgrade configuration as a duplicate, adding credit.
Comment #24
mikelutzComment #26
mikelutzClosing #3276266: Support alternative migration ID's in BlockPluginId lookups as a duplicate of this and adding credit for @fengtan and @ranjith_kumar_k_u from that issue.
Comment #28
anybody#3322542: Drupal 6 "d6_field_file" migration plugin static lookup, leads creating empty file fields was closed as duplicate. Take care if file fields not migrating in a Drupal 6 Migration, while files themselves are migrating!
Settings the priority to major here, as this issue affects many kinds of migrations using --configure-only, which is typical for larger migrations and searching the reason takes hours to days...
Just like it happened to us in that issue. once again.
Comment #29
Ankit.Gupta commentedPatch #17 applied successfully in drupal 10.1.x
Comment #30
grevil commentedCareful people, the dirty workaround from #8 doesn't work, as
$this->migrationPluginManager->createInstances($migration_id)will NOT be empty, if an id wasn't found. Instead it will throw an\Drupal\Component\Plugin\Exception\PluginException.Use attached patch for working hacky workaround.UPDATE: Doesn't work!
Comment #31
grevil commentedUpdating the issue summary to show what has been resolved already. Also I'll prepare a MR from the latest patch.
Sadly, I don't think I'm clever enough to fix the others :(
Comment #32
grevil commented@quietone:
What does that mean? As of #28 it doesn't work. Drupal 6 file fields are not correctly migrated for us. It's hard-coded and with uprade_ it's broken!
See #3322542: Drupal 6 "d6_field_file" migration plugin static lookup, leads creating empty file fields
I updated the issue summary to be clear about the status.
Comment #34
grevil commentedI created a new branch, which is up-to-date with 10.1.x and applied patch #17 by @quietone, making it a bit easier for anyone to work on this issue! :)
Comment #36
anybodyComment #38
quietone commentedThis accepts the changes in #19. And adds potential fixed for BlockVisibility and FilterFormatPermissions. Not very pretty but I think it will work.
Comment #39
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #40
quietone commentedIt is more important that this is reviewed for the approach so setting back to NR.
Comment #41
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #42
quietone commentedComment #43
smustgrave commentedWent to take a look at the MR but showing 1000+ changes which doesn't seem correct. Wonder if the MR could be fixed. Not sure what changes to look out.
Comment #44
quietone commentedComment #45
smustgrave commentedHiding patches as fix is now being worked on in MR 3198
Wasn't entirely too sure how to test.
Setup a fresh D10.1 site and D7 site
Installed the migrate modules
Did some edits to a User Login block on D7
But because of BlockVisibility.php in the IS
Changed the visibility and block title.
Ran the import and didn't receive any issues.
Block changes were imported correctly.
if there are additional changes please let me know and can test.
Comment #46
quietone commentedRereading the IS I think the proposed resolution needs an update, which I have done.
There are no unanswered questions her, although I do not see a code review since #19, and more changes were added since then. Setting back to NR for review.
Comment #47
smustgrave commentedDid the testing in #45
Comment #48
xjmComment #49
quietone commentedI'm triaging RTBC issues. I read the IS and the comments, also noted that tests are not running regularly.
This is tagged for "Needs architectural review" but there is no such review, so setting to NR.
I also rebased the MR
Comment #50
mikelutzSetting to NW to add documentation to all plugins we are creating or changing, and for a CR.
Comment #51
quietone commentedComment #52
smustgrave commentedThink a rebase went wrong as the MR is showing 1000+ file changes.
Comment #53
quietone commentedI have updated this to complete the support of previously generated d6_block and d7_block migrations.
Comment #54
quietone commentedChange record added.
And I did a more thorough self review. I found that this included changes for a different issue, so I removed those. I reworked logic in BlockVisibility and d6/FilterFormatPermission process plugins.
Comment #55
smustgrave commentedThis still need subsystem maintainer review?
Comment #56
mikelutzComment #57
smustgrave commentedAppears feedback has addressed.
core/modules/block/src/Plugin/migrate/process/RolesLookup.php to add documentation I see there is example code
* Examples
*
* @code
* process:
* roles:
* plugin: roles_lookup
* migration: d7_user_role
* @endcode
Comment #58
alisonI had an issue where block configs for a ton of my blocks, including content blocks, were failing to come in. MR #3198 fixed that problem, all my blocks that are content blocks migrated properly 🎉 A few remaining issues, and I don't know if they're related to *this* issue! -- and I don't have a ton of info yet, I just tried the patch on Friday, I'll continue hammering away at the remaining missing blocks this week and share more if I have more to share --
Meanwhile, my remaining issues that may or may not be relevant to *this* issue:
seven_user_login(but the theme setting is "theme: claro", as it should be -- so the blocks are properly configured, it's just the wrong theme name in the machine name).Comment #60
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!
Comment #63
catchComment #64
anybodyThank YOU @catch! Great to see this fixed finally :)