Problem/Motivation
When a D6 block with role-based visibility settings is migrated, the roles selected in the "Show blocks for specific roles" settings are not properly migrated. Currently, when a block with role-based visibility settings (in this case, "authenticated") is migrated, the resulting D8 configuration is:
visibility:
user_role:
id: user_role
roles:
- '2'
context_mapping:
user: user.current_user
negate: false
When it should be:
visibility:
user_role:
id: user_role
roles:
authenticated: authenticated
negate: false
context_mapping:
user: user.current_user
I'm thinking that the D6 core roles (anonymous, authenticated) should be handled in the BlockVisibility process plugin. Any D6 custom roles will need to be leverage the d6_user_role migration, I suppose?
Proposed resolution
Figure out how to properly handle core roles (anonymous, authenticated) and custom roles properly.
Remaining tasks
The work.
User interface changes
None.
API changes
None.
Comments
Comment #1
chx commentedYou can look at how BlockPluginId / block_plugin_id uses ContainerFactoryPluginInterface to get plugin.manager.migrate.process. Note that the createInstance method call could be migrated into create. Could be because the whole thing is totally unnecessary and a separate issue should be filed to remove this from block_plugin_id since d6_custom_block keeps the ids (as do every single migrate_drupal migration) so this is superflous.
Comment #2
ultimikechx,
Thanks - benjy pointed me to a bit of similar code in the FilterFormatPermission process plugin (that doesn't use createInstance). In either case, that's exactly what I'm looking for.
Thanks,
-mike
Comment #3
chx commented$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_filter_format'), $migration)sure it does. It actually does what I suggested "the createInstance method call could be migrated into create".Comment #4
ultimikeAh - yeah, I see now. I was looking in the transform method and not create.
I'll open a new issue and create a patch to fix BlockPluginId.
Thanks,
-mike
Comment #5
ultimikePatch attached, using the same method as in #2410623 to handle the d6.gz binary file. This patch also includes the new core/modules/migrate_drupal/src/Tests/.gitattributes file, and will likely have to be re-rolled once #2410623 is committed (or vice-versa). For now, let's see what the testbot says.
The Blocks.php D6 table dump has some unrelated "weight" changes in it, likely due to weight changes in other blocks related to tests in this patch. The unrelated weight changes are all for blocks that don't have an associated region, and therefore have no automated tests, so they shouldn't be an issue.
-mike
Comment #6
RavindraSingh commentedWhy this misc content is here?
I see there are some block setting getting changed on your system.
See the screenshot for the reference.
Comment #7
ultimike@RavindraSingh,
The binary portion of the patch is for the d6.gz database dump that is used for the Migrate in Core automated tests.
The block settings being changed by my system are explained by the second paragraph of my comment 5 above.
Thanks,
-mike
Comment #8
benjy commentedI think we need a more reviewable patch without the database diff.
Comment #9
lokapujyaOne for review, and one for seeing the test fails.
So I tested this locally. Changed a block to anonymous, changed one to authenticated, and created a custom block with user role visibility. They all migrated.
Comment #11
chx commentedThanks for the review patch! Restoring status: #9 is a test and a review only patch and #5 is still up for review.
Comment #12
benjy commentedNot a huge for of this name but it's the same in the FilterFormatPermission plugin so lets roll with it.
Good catch.
Rest looks good to me, RTBC.
Comment #14
alexpottMigrate is not subject to beta. Committed ef2a4a0 and pushed to 8.0.x. Thanks!
@RavindraSingh there is no need to upload a image to do code snippets. Use https://dreditor.org/ for this.