Problem/Motivation

Right now, d[6|7]_block is a monolithic migration. It would be nice to derive it per (destination) theme and per block plugin type (separating block_content block plugin instances form other ones), and skip those block migrations whose destination theme is not available.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

huzooka’s picture

Status: Active » Needs review
FileSize
6.67 KB

This patch is incomplete; it has to apply the same logic in BlockTheme::transform() (next turn).

Status: Needs review » Needs work
huzooka’s picture

Status: Needs work » Needs review
FileSize
8.62 KB
4.76 KB

Status: Needs review » Needs work
huzooka’s picture

Status: Needs work » Needs review
FileSize
11.24 KB
8.54 KB

Status: Needs review » Needs work

The last submitted patch, 6: core-derived_block_config_migrations-3115938-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

huzooka’s picture

Status: Needs work » Needs review
FileSize
11.41 KB
409 bytes
huzooka’s picture

The last submitted patch, 9: core-derived_block_config_migrations-3115938-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mikelutz’s picture

Project: Drupal core » Migrate Upgrade
Version: 8.9.x-dev » 8.x-3.x-dev
Component: migration system » Code
Related issues: +#3097336: Improve the DX for migrating content entities: view modes, fields, formatters, widgets etc should be migrated per entity type + bundle

As with #3097336: Improve the DX for migrating content entities: view modes, fields, formatters, widgets etc should be migrated per entity type + bundle, There is no reason to do this in core as you can't run the migrations separately anyway. I'm moving it to migrate_upgrade along with that issue.

huzooka’s picture

Wim Leers’s picture

#3171980: Menu migration should happen before block migration would be a good addition here, but here we could make it required!

huzooka’s picture

This patch derives also block translation migrations.

Wim Leers’s picture

  1. +++ b/core/modules/block/src/Plugin/migrate/source/d7/BlockTranslation.php
    @@ -46,7 +65,7 @@ class BlockTranslation extends Block {
    -      ->condition('i18n_mode', 1);
    +      ->condition('b.i18n_mode', 1);
    

    Nice hardening.

  2. +++ b/core/modules/block/src/Plugin/migrate/source/d7/BlockTranslation.php
    @@ -100,8 +127,12 @@ class BlockTranslation extends Block {
       public function getIds() {
    +    $ids['module']['type'] = 'string';
    +    $ids['module']['alias'] = 'b';
         $ids['delta']['type'] = 'string';
         $ids['delta']['alias'] = 'b';
    +    $ids['theme']['type'] = 'string';
    +    $ids['theme']['alias'] = 'b';
         $ids['language']['type'] = 'string';
         return $ids;
       }
    

    HUH! How did this source plugin work at all until now!

    This seems like very sensible and overdue hardening 👍

  3. +++ b/core/modules/content_translation/migrations/d7_block_translation.yml
    @@ -53,6 +54,8 @@ process:
    +          navigation: system_menu_block:main
    

    👏 — these also exist in d7_block.

Wim Leers’s picture

+++ b/core/modules/block/src/Plugin/migrate/BlockDeriver.php
@@ -163,7 +164,15 @@ class BlockDeriver extends DeriverBase implements ContainerDeriverInterface {
+        $migration_base_ids_which_may_need_content_migration = [
+          'd6_block',
+          'd7_block',
+        ];
+        $block_content_migration_dependency_is_required = $block_content_block_migration && in_array($base_plugin_definition['id'], $migration_base_ids_which_may_need_content_migration, TRUE);
         $derived_migration = $base_plugin_definition;
         $derived_migration += ['migration_dependencies' => []];
         $derived_migration['migration_dependencies'] += [
@@ -191,7 +200,7 @@ class BlockDeriver extends DeriverBase implements ContainerDeriverInterface {

@@ -191,7 +200,7 @@ class BlockDeriver extends DeriverBase implements ContainerDeriverInterface {
           unset($optional_migrations[$block_content_migration_optional_key]);
         }
 
-        if ($block_content_block_migration) {
+        if ($block_content_migration_dependency_is_required) {

In manual testing, this means that d7_block:bartik:block_content now gets a required dependency on d7_custom_block 👍

This was a bug in all preceding patches.

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
FileSize
19.3 KB
7.06 KB

Core BlockTranslation (d7_block_translation) has a buggy query.

This new patch fixes it, and makes us get rid of the duplicated plugin and theme processes: since the default migration d7_block already calculated these, and they were required only by the entity:block destination plugin.

Wim Leers’s picture

Manually tested, works great! 🥳

huzooka’s picture

Liam Morland’s picture

Status: Needs review » Needs work

The patch does not apply because it is for Drupal core. If this is to be fixed in core, this issue needs to be moved back there. Otherwise, the patch needs to be for migrate_upgrade.

mikelutz’s picture

We aren't doing this in core. The issue was moved here intentionally, but yes, it requires a completely different approach to do it in this module.

Wim Leers’s picture

Wim Leers’s picture