Problem/Motivation

When blocks are migrated from D6 to D8, they are usually not placed in any region, unless the D8 site has the same theme as the D6 site.

Proposed resolution

Theme property

When deciding which themes the block belongs to: blocks belonging to the D6 default theme will belong to the D8 default theme, the D6 admin theme if there was one, becomes the D8 admin theme, for everything else the we just put in the theme property unchanged. This is going to cover a great majority of cases which is our goal with this migrate path -- in fact, just the first two already covers the most common case where there is only the default and the admin theme.

For regions

  • If the same-named theme is present on D6 and D8, then the value of the region setting for the block does not change.
  • Map (left=>sidebar_first,right=>sidebar_second) a few common regions.
  • Keep some regions (sidebar_first,sidebar_second, help, header, footer).
  • Fall back and dump the blocks in the "content" region. It is guaranteed to exist and is visible everywhere.

As part of this patch, the d6_system_theme migration gets removed and themes join modules in the list of things we do not migrate. It's not too surprising: even core changed themes from D6 to D8 and so the old approach of copying the theme names over didn't work anyways... Documented https://www.drupal.org/node/2167633 here.

Remaining tasks

None.

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#74 d6_block_mapping-2248407-74.patch22.89 KBhussainweb
#74 interdiff-72-74.txt1.06 KBhussainweb
#72 d6_block_mapping-2248407-72.patch22.77 KBhussainweb
#69 interdiff.txt1.32 KBbenjy
#69 2248407-69.patch23 KBbenjy
#63 interdiff.txt1.81 KBultimike
#63 d6_block_mapping-2248407-63.patch23.08 KBultimike
#62 interdiff.txt1.31 KBultimike
#62 d6_block_mapping-2248407-62.patch22.94 KBultimike
#61 interdiff.txt1.84 KBultimike
#61 d6_block_mapping-2248407-61.patch22.94 KBultimike
#60 interdiff.txt4.26 KBultimike
#60 d6_block_mapping-2248407-60.patch22.94 KBultimike
#58 d6noncore.info143 bytesjp.stacey
#43 interdiff.txt4.34 KBultimike
#43 d6_block_mapping-2248407-43.patch22.37 KBultimike
#42 marvin.info.yml178 bytesultimike
#41 marvin.info.yml181 bytesjp.stacey
#41 2248407-block-theme-regions-manual-testing.txt1.4 KBjp.stacey
#38 marvin.info.yml146 bytesjp.stacey
#37 2248407-block-theme-regions-manual-testing.txt1.92 KBjp.stacey
#34 interdiff.txt3.34 KBhussainweb
#34 d6_block_mapping-2248407-34.patch19.04 KBhussainweb
#30 block_mapping-2248407-29.patch18.79 KBultimike
#28 block_mapping-2248407-28.patch19.31 KBultimike
#28 interdiff.txt2.38 KBultimike
#26 interdiff.txt1.69 KBultimike
#26 block_mapping-2248407-26.patch19.23 KBultimike
#24 interdiff.txt3.17 KBultimike
#24 block_mapping-2248407-24.patch19.26 KBultimike
#22 block_mapping-2248407-22.patch19.25 KBultimike
#18 block_mapping-2248407-18.patch21.28 KBultimike
#17 block_mapping-2248407-17.patch21.26 KBultimike
#15 block_mapping-2248407-15.patch9.63 KBultimike
#13 block_mapping-2248407-13.patch9.67 KBultimike
#9 block_mapping-2248407-9.patch9.59 KBultimike
#7 block_mapping-2248407-7.patch8.02 KBultimike
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike’s picture

Issue summary: View changes
chx’s picture

Project: IMP » Drupal core
Version: » 8.x-dev
Component: Code » migration system
Issue summary: View changes
webchick’s picture

Seems like a reasonable approach. The only other thing I'd recommend is a step between 2&3 where you attempt to match with the default region names that are defined in https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ThemeHa.... If you take the top ~10 base themes in D6 and see what they called those things, one additional step could map e.g. "left", "sidebar_left", "left_sidebar", etc. to "sidebar_first." Not sure if that's possible or not, but it'd be nice, since barfing things into the content region's definitely not going to be what people want (though certainly better than not showing up at all :D).

chx’s picture

Issue summary: View changes
chx’s picture

Issue summary: View changes
ultimike’s picture

Okay, sounds like a plan, I'll see what I can do.

On a related note, I mentioned to chx that I thought there was a migration bug with migrated custom blocks interfering with existing D8 custom blocks. I tested it some more and opened a new issue: https://drupal.org/node/2248691

Thanks,
-mike

ultimike’s picture

A rough version of a patch is attached. I have things partially working, but I was hoping for some feedback before continuing.

So far, the patch covers the case where the source and destination theme names are the same (the easy part) and a portion of mapping Drupal 6 core themes to Drupal 8 core themes. So far, I'm just mapping all D6 core theme regions to Bartik. The fallback case (when in doubt, put the block in the main content region) is in there as well.

I created the region map as a PHP array (in \Drupal\migrate_drupal\Plugin\migrate\Process\d6\BlockRegion.php), and I'm not sure if that is the best way to do it. It appears to work, but if there's a better way, I'm happy to adjust.

I'm seeing one thing I can't explain that I could use some assistance on - in my manual testing, I have 2 custom blocks on the source site, both in the same region. After migration, only one of the blocks is placed in the correct region - the other block isn't placed at all...

Here's the manifest that I used for manual testing (more details on my source and destination site configuration: https://drupal.org/node/2248691):

# blocks
- d6_block
- d6_menu

# custom blocks
- d6_custom_block
- d6_filter_format

Thanks,
-mike

P.S. Rats - I just noticed that the part of the region map for bluemarine has a bug. I'll fix it locally and include the fix in a future patch. For now, don't try to migrate from a D6 site with Bluemarine as the default theme...

chx’s picture

Status: Active » Needs work

Thanks, this is looking quite great!

\Drupal::config('system.theme')

This should be injected. See for example core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php on how to write an injecting plugin; that one uses $container->get('config.factory'), you could directly go for $container->get('config.factory')->get('system.theme') and inject the config object itself.

+ if (($this->isSourceCommonTheme($theme)) && ($theme == $d6_default_theme) && ($this->isDestinationCoreTheme($d8_default_theme))) {

I don't quite understand this logic. I thought we will always map default to default and admin to admin.

+ $this->adminTheme = $this->variableGet('admin_theme', $this->defaultTheme)

Shouldn't we just set the default to NULL and skip the second half of the mapping I just mentioned if the admin theme is empty?

Drupal 8 does not have a status but it doesn't matter; this is here the

Should be: this is here to. Yes, I wrote it. Wrong nonetheless.

+ private function

Never use private unless you have some really, really good reason to.

Please rename getRegionMap to getCoreRegionMap in anticipation of the followup which will be themeless region mapping.

ultimike’s picture

@chx,

Thanks for the patch review.

  1. I updated the config stuff, I haven't worked with it before, so it was a bit of a lesson. Hopefully, I did it as requested (I can verify that it works!)
  2. The theme matching logic - yeah, I'm not sure what I'm doing is best yet. See below for details...
  3. You're right about the admin theme In Drupal 6. If there's no admin theme set, then it doesn't matter if any blocks are assigned to it, so we can ignore it.
  4. I changed private to protected.
  5. I updated getRegionMap to getCoreRegionMap.
  6. Is the way I set up the array in getCoreRegionMap() the best way to set up the region map?

Theme matching logic

Here's what I'm thinking, there's probably a better way of doing it, I just haven't thought of it yet. Input welcome.

   // D6 theme and D8 theme are the same - sweet!
    if (($theme == $d8_default_theme) || ($theme == $d8_admin_theme)) {
      return $theme;
    }

If the name of the D6 source theme the block is assigned to ($theme) is same as the name of the D8 destination default theme, then assume it's the same theme with the same regions and just pass the name of the theme to the region plugin. This goes regardless of if we're dealing with the default (public) theme or admin theme. In theory, we can remove this block of code because of the final "return $theme;" below.

    // Core or commonly-used base theme on source for default theme, and core theme used on destination.
    if (($this->isSourceCommonTheme($theme)) && ($theme == $d6_default_theme) && ($this->isDestinationCoreTheme($d8_default_theme))) {
      return $d8_default_theme;
    }

This is the case where we're looking to see if

  1. The D6 source theme the block is assigned to is a core or commonly-used theme.
  2. The D6 source theme the block is assigned to is the current default theme on the D6 source site.
  3. The D8 destination theme is a core theme.

If these three conditions are met, then we know that we can (and should) map the source region the block is assigned to its corresponding D8 destination region.

    // Core or commonly-used base theme on source for admin theme, and core theme used on destination.
    if (($this->isSourceCommonTheme($theme)) && ($theme == $d6_admin_theme) && ($this->isDestinationCoreTheme($d8_admin_theme))) {
      return $d8_admin_theme;
    }

This uses the exact same logic as the previous case, but for blocks assigned to an admin theme.

    // No luck, we'll assign this block to the main content region in d6_block_region.
    return $theme;

At this point, the source and/or destination themes are something can't handle, so we bail.

There's still work to do, consider this patch just a proof-of-concept. If what I have so far looks good, then I'll go ahead and add the rest of the mapping.

Updated patch attached.

Thanks,
-mike

chx’s picture

This is way better than a proof of concept, really! I think it just needs to flesh out the block test and it's done.

> Is the way I set up the array in getCoreRegionMap() the best way to set up the region map?

Yes.

Now, theme logic. Your theme logic wants to map only if the region map will have a chance to match. But that's not relevant for theme mapping IMO. Even if the core migration does not have the necessary region mapping for the case when the user changes their theme from D6 to D8 it can easily be altered in. I think we should honor what the user wants and map default to default and admin to admin:

+  public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) {
+    list($theme, $d6_default_theme, $d6_admin_theme) = $value;
+
+    $d8_default_theme = $this->config->get('default');
+    $d8_admin_theme = $this->config->get('admin');
+
+    if ($theme == $d6_default_theme) {
+      return $d8_default_theme;
+    }
+
+    if ($theme == $d6_admin_theme) {
+      return $d8_admin_theme;
+    }
+
+    return $theme;
+  }
ultimike’s picture

chx - I see what you're saying. In d6_block_theme, we're not going to worry if the region map returns a valid region. Like you said, we're going to honor what the user is trying to do.

I'll go ahead and make the suggested change and flesh out the region map and post an updated patch.

Thanks,
-mike

chx’s picture

Exactly! Because the region map will always return a valid region -- it's just going to fall back to content a lot of times in the uncovered cases.

ultimike’s picture

An updated patch with the changes outlined in comments 10-12 above attached.

While testing this, I'm pretty sure I found a bug in the d6_block migration having to do with unique names. I opened a new issue here: https://drupal.org/node/2250429. The bug is preventing me from fully testing this patch.

Thanks,
-mike

chx’s picture

Issue summary: View changes
ultimike’s picture

At this point, I think that as soon as https://drupal.org/node/2250429 lands, then this one will be ready to go as well. I'm attaching a slightly updated patch with a minor change that I made based on testing.

Applying this patch and https://drupal.org/node/2250429, I can successfully migrate and map custom blocks from D6 into D8. More testing is required, but things are looking good.

-mike

ultimike’s picture

Need to add additional tests to Drupal\migrate_drupal\Tests\d6\MigrateBlockTest for theme/region mapping.

-mike

ultimike’s picture

Issue summary: View changes
FileSize
21.26 KB

An updated patch is attached. This patch is meant to be applied after #2250429: d6_block migration not migrating all blocks is committed.

Changes include:

  1. Removed some of the MigrateBlockTest assertions, all because of the addition of the skip_row_on_empty process plugin (based on the block's "status" field) to the d6_block.yml.
  2. Updated MigrateBlockTest assertions with proper theme and regions based on the new mapping scheme.
  3. I removed the d6_system_theme.yml, MigrateSystemThemeTest.php (and associated dump file), and removed references to MigrateSystemTheme from MigrateDrupal6Test.php. This is based on a chat with chx where we realized that if we continue to migrate the D6 default and admin theme setting, the theme and region mapping logic in this patch is moot.
  4. Because we want the MigrateDrupal6Test to have Bartik and Seven set as the D8 theme (to test block theme and region mapping), I added a MigrateDrupal6Test->setup() method that sets the D8 default and admin theme.

I've tested this patch by running:

  1. MigrateBlockTest
  2. MigrateDrupal6Test
  3. A custom migration from a real-ish Drupal 6 test site with five custom blocks (assigned to different regions), numerous blocks from core modules enabled, and several enabled themes (with Garland as the default).

At this point in time, I think we're in good shape.

Thanks,
-mike

ultimike’s picture

Status: Needs work » Needs review
FileSize
21.28 KB

Now that #2250429: d6_block migration not migrating all blocks has been committed, I've re-rolled this one - it's ready for the testbot and review.

I've create a new issue for webchick's request for coverage of the top 10-ish base themes: #2265907: Block Migration mapping for widely-used contributed themes.

Thanks,
-mike

chx’s picture

Status: Needs review » Needs work
  1. return $destination_region = FALSE; is very weird while works just return FALSE.
  2. mapping to content is always pointless. No mapping results in content too.
  3. Looking at these results, if we were changing left and right to sidebar_first and sidebar_second respectively then check whether the results are in the region list of the target theme then we would kill a lot of birds with a single stone: core, contrib, all. Yes this is not what's in the issue summary but look at your mappings. There's some presumption here that I thought dangerous before but I'll boldly go where no man has gone before and claim that left, right, header and footer are such strings where merely the string is enough to derive a semantic meaning from without knowing the theme. https://api.drupal.org/api/drupal/core%21modules%21system%21system.modul... is your friend.
ultimike’s picture

Thanks for the code review. Number 1 and 2 are no problem.

For number 3, perhaps we can do away with the entire getCoreRegionMap() and just look for certain region names and map those regardless of the theme? I like that idea, it really simplifies things. We can always map "left" to "sidebar_first", "header" to "header", etc... Instead of having complete maps for widely used themes, we can just map widely used region names and be correct most of the time for all core, contrib, custom themes.

Thoughts?

Mike

chx’s picture

Yes, that's exactly what I had in mind, just map those names. When I wrote the IS , I was thinking too many contrib region names won't have a good match but I didn't realize core was so uniform and few regions.

ultimike’s picture

Status: Needs work » Needs review
FileSize
19.25 KB

chx,

I took a step back and was thinking about this a bit more, asking myself, "what is the most common migration scenario going to be"? I'm thinking:

  1. Migrating from a custom or contrib theme to the same-named theme.
  2. Migrating from a custom or contrib theme to a core theme.
  3. Migrating from a custom or contrib theme to a different non-core theme.

I think that 1 and 2 will be the vast majority. Plus, those in 3 will not expect blocks to be migrated to the proper region.

So, we already have number 1 taken care of (same-named theme, we map regions directly). Number 2 should be able to be taken care of using the methodology we've been discussing in the previous few comments.

I've attached an updated patch, no interdiff though (sorry!)

Thanks,
-mike

chx’s picture

This is becoming really great.

Sorry for being so slow in realizing things but as I see the code forming so do my thoughts answer to it. The default_region_map really ought to be a region_map in the YAML so that contrib can easily change it, don't you think so?

I still think the theme logic in #10 would be enough. if ((strtolower($theme) == strtolower($d8_default_theme)) || (strtolower($theme) == strtolower($d8_admin_theme))) this is the difference and it only makes a difference if there is a non-default theme in D6 which happens to have the same name as the d8 default. That doesn't seem too realistic to me? But we could simply check whether the theme from d6 is neither default nor admin and exists in d8 and if yes leave alone:

$themes = \Drupal::service('theme_handler')->listInfo(); // inject this.
if (isset($themes[$theme])) {
  return $theme;
}
// If the source block is assigned to a region in the source default theme, then assign it to the destination default theme.

etc.

ultimike’s picture

FileSize
19.26 KB
3.17 KB

chx,

I've updated the patch as you suggested, simplifying the theme mapping and moving the region mapping configuration into the d6_block.yml. I modeled the region mapping configuration and code from the static_map process plugin. It seem to me like we can almost use the static_map process plugin directly - thoughts?

I'm also thinking about if/how we can add some additional automated tests to this. Currently, we're only testing the case where the destination theme is bartik. Seems to me like we should also be testing at least one other (non-core) destination theme.

New patch and interdiff attached.

Thanks,
-mike

chx’s picture

I do not think you could easily get this into a multi step process with one step being the custom plugin and another being a static map because they are not pipeline-ish -- their sources are different and they are independent. I am not sure why is nestedvalue used, however. That's what static map is using, yes, but we have a very small source=>destination style map here, nothing on the level of staticmap. if (isset($map[$region])) return $map[$region] should suffice, i'd guess?

ultimike’s picture

FileSize
19.23 KB
1.69 KB

chx,

I was using the NestedArray stuff because I was modeling it after the static_map plugin. You're correct, just a simple issset() should work. I've updated the patch accordingly.

As for additional tests, here's what I'm thinking: the current MigrateBlockTest only tests the case where the destination theme is a core theme (case 2 from comment 22 above). Do you think we need to add a new test for the case of migrating from a non-core theme to the same theme in the destination. If so, what is the best way to do that? Seeing how we set the destination theme in MigrateBlockTest->setup(), would I need to create an entirely new test? I don't think something like the following would work because then all of the theme- and region-related assertions would be wrong the second time we run the migration (with 'zen' as the active destination theme).

    // Existing MigrateBlockTest->setup() code...
    $config = \Drupal::config('system.theme');
    $config->set('default', 'bartik');
    $config->set('admin', 'seven');
    $config->save();

    /** @var \Drupal\migrate\entity\Migration $migration */
    $migration = entity_load('migration', 'd6_block');
    $dumps = array(
      $this->getDumpDirectory() . '/Drupal6Block.php',
    );
    $this->prepare($migration, $dumps);
    $executable = new MigrateExecutable($migration, $this);
    $executable->import();

    // ...maybe add something like this...
    $config->set('default', 'zen');
    $config->save();
    $executable->import();

-mike

chx’s picture

I will get back to the testing but

  1. the block region mapping is seriously bad ass
  2. the theme mapping already has the scaffolding in place for injection, please inject $container->get('theme_handler')->listInfo(). Makes (theoretical) unit testing quite easy cos that's just an array, isn't it.
  3. On that note the two config gets call can be moved down after the theme exists check. Microoptimization, yes, but why not when it costs nothing?
ultimike’s picture

FileSize
2.38 KB
19.31 KB

chx,

Good idea on the theme_handler stuff. I feel like I'm starting to have a feel for the ContainerInterface object and injecting data...

Updated patch and interdiff attached.

Thanks,
-mike

brockfanning’s picture

Is the patch meant to be applied in the core root directory? I'm getting errors when I try, due to some non-existent file paths, like:
core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/Dump/Drupal6SystemTheme.php

ultimike’s picture

FileSize
18.79 KB

@brockfanning - I just needed to re-roll the patch for PSR-4. Try this one...

Thanks,
-mike

brockfanning’s picture

Thanks @ultimike: I did a simple migration with the latest patch applied and this worked as advertised.

benjy’s picture

This is looking good ultimike, really great work.

Just a few super minor doc issues and then I think this is RTBC.

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockRegion.php
    @@ -0,0 +1,44 @@
    +    // Theme is the same on both source and destination, we will assume they have the same regions.
    

    comments should be less than 80 characters.

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockRegion.php
    @@ -0,0 +1,44 @@
    +    // If the source and destination theme are different, try to use the mappings defined in the configuration.
    

    comments should be less than 80 characters.

  3. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockTheme.php
    @@ -0,0 +1,95 @@
    +   * @param \Drupal\Core\Config\Config $config
    +   *   The configuration factory object.
    +   */
    +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, Config $config, array $themes) {
    

    Missing @param comment for $themes.

chx’s picture

> comments should be less than 80 characters.

on one line, you just need to break them up.

hussainweb’s picture

FileSize
19.04 KB
3.34 KB

I just rerolled the patch against the latest HEAD and fixed comments in #32 and a couple others I found. I hope to see this committed soon.

hussainweb’s picture

Status: Needs review » Needs work

Hmmm... It does not seem to want to test the patch. Maybe I should flip the status once?

hussainweb’s picture

Status: Needs work » Needs review

Setting back to needs review to test the patch in #34.

UPDATE: Okay, it doesn't look it is working. Any ideas?

UPDATE 2: Okay, it finally worked (and the tests pass). It might be a delay.

jp.stacey’s picture

Unfortunately the patch in #34 failed my manual testing just now.

I've attached a detailed manual test script to cover as many of the situations in this issue's description as possible. Please let me know if there are any situations it doesn't cover. It tries to make e.g. the manual equivalent of "fixtures" as explicit as possible. However, in the absence of a similar-named theme in D6 and D8, it's hard to test everything. Also it would be good to get some guidance on what happens to any e.g. D6 "Bluemarine" configuration: should that be silently dropped?

With that in mind, here's a report of the results of my testing.

I patched D8 with the patch from #34 and then ran the migration using the manifest inline in the test script, with d6_block_region and d6_block_theme explicit. However, when I did so, I didn't get any mention of those two migration plugins:

$ drush migrate-manifest --db-url=mysql://d6mig:d6mig@localhost/drupal6_migration /var/www/drupal8-migration-manifests/D6Manifest-Block-Theme.yml
Running d6_filter_format            [ok]
Running d6_custom_block             [ok]
Running d6_menu                     [ok]
Running d6_block                    [ok]
$ 

Here's what I saw in the D8 admin interface. I cleared caches to make sure I wasn't missing anything.

Test 1

Custom block C1:

  • PARTIAL: D6 admin description became D8 block "title" (/admin/structure/block) or "description" (/block/1) - these are the same in D8?
  • FAILURE: D6 block title itself not migrated
  • SUCCESS: D6 body & text format migrated
  • FAILURE: Visibility:pages not migrated
  • FAILURE: Visibility:roles not migrated
  • FAILURE: Garland "header" region not migrated

I'm not sure what metadata is currently supported by d6_block, but obviously the last item is the kicker for this particular issue.

Custom block C2:

As C1 above; the region "left"=>"sidebar_left" was not migrated either.

Tests 2-4

Can't test (see comments in test script re what should happen to Bluemarine, and how to test "theme with the same name".)

jp.stacey’s picture

FileSize
146 bytes

Here's an option for testing migration of a theme with the same name: a stub "Marvin" theme in D8, with just a "content" region (to also be able to test what happens when "left"/"sidebar_left" doesn't exist in the D8 equivalent theme.)

I've attached an info.yml file for comment, to be saved to sites/default/themes/marvin/marvin.info.yml.

ultimike’s picture

jp.stacey,

I think I'm a little confused by your last two comments - this issue is mainly geared toward block mapping from one theme/region to another, not individual properties of blocks (title, body, text format, etc...) There's at least one issue (#2281393: D6->D8 Blocks - Custom titles not imported) that involves issues like this.

That being said, it looks like you're on the right track for some of this (I like the idea of using a D8 theme stub for testing).

With this in mind, is the patch in #34 working for your manual tests?

Thanks,
-mike

jp.stacey’s picture

Sorry, I think I was misunderstanding "everything else gets copied" up in the original issue description as meaning "all the block metadata" (visibility etc.): is it worth me opening separate issue(s) for that, to look at the issue(s) independently?

Unfortunately the main thrust of this issue - the theme/region copying - didn't work. This was buried a bit in my discussion of the block metadata but here are the salient bits of my comment #37 above:

C1: FAILURE: Garland "header" region not migrated
C2: the region "left"=>"sidebar_left" was not migrated (either)

This was trying to copy from Garland (D6 default) from Bartik (D8 default.) I didn't get much further than that as I had enough negative results that I wanted to make sure I was on the right track!

... Tell you what, for clarity's sake, I'll run through my tests again - including "D8 Marvin", but not including any discussion of block metadata - and report back when I've done so.

jp.stacey’s picture

FileSize
1.4 KB
181 bytes

I've redrafted the testing script (and edited marvin.info.yml to use the right) and run it locally, and I can confirm a partial success.

I've a couple of queries which I think are worth clarifying:

* The manifest in the testing script currently states d6_block_theme and d6_block_region explicitly: is that necessary?
* When a theme doesn't exist in D8 (e.g. Bluemarine in the testing script) what's the result? Should the configuration be silently ignored? Is there any way of checking that at the database/config layer? This edge case is the final test in the testing script.

Anyway, here are my results in full.

Drush output

Here's the output from running my Drush command (whitespace edited slightly to stop it looking crazy):

Running d6_menu                                                             [ok]
Running d6_filter_format                                                    [ok]
Running d6_custom_block                                                     [ok]
Running d6_block                                                            [ok]
The block block_4 was assigned to the invalid region right and has been disabled.
                           [warning]
The block block_5 was assigned to the invalid region left and has been disabled.
                            [warning]

As you can see, it's treated both "right" and "left" as invalid regions (probably for Marvin; see below.)

Test 1: Migration Garland=>Bartik (because default theme)

SUCCESS: C1 migrated Garland header=>Bartik header
SUCCESS: C2 migrated Garland left=>Bartik sidebar_first

Test 2: Migration Marvin=>D8 Marvin

FAILURE: C1 migrated Marvin right=>D8 Marvin disabled (should be migrated into content as per issue description: 'blocks will be dumped in the "content" region in D8.'
FAILURE: C2 migrated Marvin left=>D8 Marvin disabled (should be in sidebar_first as per mapping)

Test 3: Migration Bluemarine=>No candidate in D8

I'm assuming this configuration should be dropped, but maybe we need a way of knowing whether or not it's been unintentionally saved in D8 against a nonexistent "bluemarine" theme.

ultimike’s picture

FileSize
178 bytes

@jpstacy,

First off, you are correct in that calling d6_block_theme and d6_block_region explicitly in the .yml is not necessary.

Really great work on the tests, thanks for taking the time to dive into this.

Regarding your test 2 (Marvin), the d6_block_region process plugin assumes that if the same theme exists on both the source and destination, then the available regions will be the same, and no region mapping is performed:

   // Theme is the same on both source and destination, we will assume they have
    // the same regions.
    if (strtolower($source_theme) == strtolower($destination_theme)) {
      return $region;
    }

I've attached a new marvin.info.yml file with the same regions as appear in D6. I've re-run the same manual test as yours, and the results are as I expect:

  • C1 migrated from Marvin right in D6 to Marvin right in D8.
  • C2 migrated from Marvin left in D6 to Marvin left in D8.

For your test 3 (Bluemarine), as you surmised, if the D6 theme doesn't appear in D8, then there's not much we can do, and we bail. We can't account for every situation, and site builders should expect that if they migrate a D6 site into a fresh D8 site where the D6 theme doesn't exist, they're going to have to reset their block placements.

I still think we need an additional test for block migration from a non-core source theme to the same theme in the destination (see my comment 26 above). I chatted with benjy about this in IRC and he pointed me to D8 test themes in /core/modules/system/tests/themes/ that we can probably leverage. I'm working on this now.

Thoughts?

Thanks,
-mike

ultimike’s picture

FileSize
22.37 KB
4.34 KB

Attached is an updated patch (based on #34 - thanks hussainweb!) that adds additional tests for mapping blocks in non-core themes.

Thanks,
-mike

jp.stacey’s picture

@ultimike: the Marvin behaviour makes sense, but maybe the description of this issue doesn't make this behaviour clear? Perhaps when we get round to writing a change report (are those happening for IMP?)then we can make this all absolutely explicit.

On that note I'm happy for at least one of the test results to be a negative e.g. actually test that not-same-region-if-same-theme-name gets dropped. It's part of the complex behaviour anyway. So maybe let's have a marvin.info.yml with one region name the same, and one different (but a valid D8 mapped region, so we make explicit what's happening - or not - with those.)

If we're testing behaviour for non-core themes, is it a valid test, to use the D8 "with-core" test themes? Don't they still count as "basically core"? Would it be better to just create a D6 noncore.info and a D8 noncore.info.yml and add a fourth test to the script? (Do we indeed expect non-core themes to behave differently from e.g. Marvin in our tests? Just checking!)

And I've thought of a potential (negative) test to ensure Bluemarine is being "forgotten about": grep the config directories for Marvin, and then for Bluemarine? It would ensure good housekeeping (that config isn't accidentally being saved, just in an "invisible" way because the theme doesn't exist.)

jp.stacey’s picture

(@ultimike PS I won't do any more testing until I hear your thoughts re using an in-core test theme rather than a mocked up noncore.info. But then I'll do so, and tidy up marvin.info.yml and the test script and hopefully have something final!)

ultimike’s picture

@jp.stacey,

I'm not sure we need to add a marvin.info.yml at all - we should probably just stick with the test themes provided in drupal8/core/modules/system/tests/themes. Those are "core" themes, they are themes created specifically for automated tests like this. We can add to them if we'd like (as I did for one of the tests in the patch) to test exactly what we're looking for.

I understand your concerns, but I think we really just need to try to take care of the 80%. In the vast majority of cases, I think that when someone is doing a D6->D8 migration, they'll most likely fall into one of these categories:

  1. They're migrating from a contrib or custom theme into a core D8 theme.
  2. They're migrating from a contrib or custom theme into a the same named-theme (and we assume they have the same regions).
  3. They're migrating from a core D6 theme into a core D8 theme.

This is the 80%, we think.

I think that all other categories involve migrating from one theme to another where the migrator has no expectation that theme or region mapping will/can be successful. This is the way previous major version upgrades have gone.

They way we wrote the block region plugin, the region mapping is in configuration, making it possible to be overridden if the migrator so desires.

I'm not sure I follow this:

And I've thought of a potential (negative) test to ensure Bluemarine is being "forgotten about": grep the config directories for Marvin, and then for Bluemarine? It would ensure good housekeeping (that config isn't accidentally being saved, just in an "invisible" way because the theme doesn't exist.)

Can you elaborate?

If you agree that this patch adds good functionality and doesn't break anything, let's push to get it committed. Then if you're so inclined, we can work on improving it.

Sound like a plan?

Thanks,
-mike

jp.stacey’s picture

@ultimike,

Your three points sound fine, but I might rephrase them as:

1. They're migrating from a contrib or custom theme (set to default) into a core D8 theme (set to default) (otherwise nothing will migrate if the theme names are different)
2. They're migrating from a contrib or custom theme into a the same named-theme (and we assume they have the same regions).
3. They're migrating from a core D6 theme into a core D8 theme (both set to default, as core D6 and D8 themes have no namespace overlap now Garland's gone)

This is mostly what I've been testing anyway, but I'm happy to formalize it like this. With my caveats added, a valid test of our point 2. entails a D8 theme with the same name as a D6 theme. Otherwise nothing will migrate, unless they're both set to default (in which case, we're just testing point 1 again.) If we're able to add such a test candidate then let's definitely do that with e.g. Marvin in core/modules/system/tests/themes/marvin.

To elaborate on that final point, one of the key problems with D5->D6 and D6->D7 upgrades has been cruft: stuff that isn't understood by the next major Drupal version but, given the database remains in situ, sits around and can sometimes cause later work to trip over itself (phantom database tables etc.)

However, this does seem to be the case with the D6->D8 migration: bluemarine config ends up in the database:

mysql> SELECT uuid FROM block_content;
+--------------------------------------+
| uuid                                 |
+--------------------------------------+
| 4674f1dd-4154-4f6f-b000-b03aca226642 |
| 759e8b3e-9aa6-4397-9b00-e613e3b27767 |
+--------------------------------------+

mysql> SELECT collection, name FROM config WHERE data LIKE '%4674f1dd-4154-4f6f-b000-b03aca226642%' AND data LIKE '%bluemarine%';
+------------+-------------------+
| collection | name              |
+------------+-------------------+
|            | block.block.block |
+------------+-------------------+
1 row in set (0.01 sec)

I don't know whether this is an issue or not. I imagine most people would expect bluemarine config to not be migrated if there's no D8 bluemarine theme, though. Would this config get cleared out later, or persist?

ultimike’s picture

@jp.stacey,

I think we're in agreement on the three points, your way of stating them is a bit clearer than mine - thanks!

As for the cruft being left behind, you're right, sometimes that can be an issue and we should minimize it as much as possible. I'm thinking that in your example above, the "block.block.block" is a result of a D6 block configuration (in the Bluemarine theme) that was migrated, but not assigned to one of the D8 themes as a result of the logic in place.

Do we not migrate the block configuration in this case (to avoid creating cruft)? I think we should migrate it, for if Bluemarine is enabled post-migration, that might be useful. I'm not sure what the correct answer is here. Thoughts?

Thanks,
-mike

jp.stacey’s picture

@ultimike I wouldn't want to propose Migration-in-core policy off the top of my head, but what I would say is that my experience of D6->D7 migrations using migrate_d2d is that it's very restricted in what it will migrate: obviously, you only ever migrate the nodes that you declare in your Migration::query() run on the D6 database. And if a field didn't exist on the D7 node, then your code to migrate it would be ignored: it's not as though the field would get implicitly created. But at times it was even more brutal than that: if you don't enable modules like Date Migration, then as far as I could tell certain Date API fields or functionality would get quietly left behind in D6.

I suppose it comes down to user expectations. Given how Migrate in D7 behaves, and what people will be used to or expect, then what do we do with configuration that has no valid home in D8, at the point of migration? I'm happy to be guided by voices more knowledgeable than me, though, especially as this is an odd edge case, where the block exists, and the concept of a block<->themeregion relationship can be said to exist, even if the theme (bluemarine) does not.

(I'd also add my experience as someone taking over a D5 site that we upgraded - not migrated - to D6. Every once in a while we'd turn a module on and the site would go bananas, because of cruft arising from functionality that other developers never fully uninstalled from the original D5 site. A D5->D6 or D6->D7 upgrade could arguably be said to be in that sense too inclusive, as it leaves any unrecognized tables in the database.)

chx’s picture

Cruft is better than leaving data behind. That's my two cents. You might want to slice this policy off into a meta issue and write a gdo/core post about it and get community buy in.

benjy’s picture

I think the way the D7 migrate module worked by quietly leaving stuff behind was probably a downfall which was much harder to overcome for D7 migrate.

We now have the ability to migrate everything and I think bringing everything across, even if that means a few extras is probably the right behaviour. It's not doing any harm and it would be a nice surprise to enable your theme and have all the block placements "just work".

jp.stacey’s picture

Well, I'm happy to go for the consensus opinion within the bounds of this specific issue here - and as chx says, if anyone wants to fight it out, there's always the possibility of opening another issue for it.

@ultimike, regarding your three items: here's what I think we require, to test them validly:

1. Non-core D6 theme (could just be a .info file.) set to default; core D8 theme set to default.
2. Non-core D6 theme and non-core D8 theme, of the same name, not set to default.
2. Garland (D6) and Bartik (D8), both set to default (would need to be run on a clean build, to avoid results confusion with 1.)

Does that sound right?

mikeryan’s picture

The D7 migrate_d2d's primary use case was to perform Drupal-to-Drupal migrations where the site architecture was being changed along the way - say, reducing 128 content types to a mere two dozen (true - the first project leading to migrate_d2d), it was never intended to be a substitute for the upgrade process and thus never attempted to migrate configuration/metadata. The D8 core migrate_drupal module, on the other hand, is meant to be the primary upgrade mechanism for upgrades to Drupal - this use case, of course, does require preserving everything on the original site.

ultimike’s picture

@jp.stacey,

Are you comfortable adding the missing (test) pieces that you outlined in comment 52?

-mike

jp.stacey’s picture

Assigned: ultimike » jp.stacey

@ultimike, I've run out of time today (although I've got dev sites set up on my work laptop now.) I'm travelling tomorrow but I hope I can look at this on Friday when I'm co-working remotely. I can provide the files but I might need advice on exactly where to roll them into the patch for #43.

One thing I did just notice - doing `drush si` on a patched codebase, I got the error:

PHP Fatal error:  Call to a member function getDirectoryPath() on a non-object in /var/www/personal/drupal8-migration/core/modules/image/src/Routing/ImageStyleRoutes.php on line 29

I had to switch back to the 8.x branch to install, and then patch afterwards. I'll try to repeat this Friday but if you're able to check in the mean time that'd help.

jp.stacey’s picture

(Re bug above: nvm, I think this was owing to doing `drush si` more than once; not sure if all the config folders or tables get cleared out properly, so I'm just DROPping the db each time now.)

ultimike’s picture

@jp.stacey,

Sounds good - I'm traveling the next few days, but I'll check this issue for updates and provide assistance as necessary.

Thanks,
-mike

jp.stacey’s picture

FileSize
143 bytes

@ultimike,

I did "drush si testing" but in the admin interface I couldn't see any of the themes in core/modules/system/tests/themes. So while they can be used for automated testing, I'm not sure they'll help with manual testing.

Here's a summary of the files needed, broken down for each manual test:

1. D6 theme info file (attached to this comment); D8 uses a core theme.
2. Can we just do this with Marvin? In which case, D6 just uses core marvin and D8 uses marvin.info.yml: neither of them set to default. Otherwise we'll need a new D8 info.yml file to go with the D6 theme info file.
3. No new files required.

If we're able to use Marvin for test 2 (I'm still trying to think what using non-core themes will gain us) then that's all we need: a new D6 .info and the marvin.info.yml.

(Note that each test now need to each be run on fresh D6 and D8 installs: the block config in D6 theme X is likely to get conflated with the block config in D6 theme Y. So the testing script I used above isn't really valid any more.)

benjy’s picture

@jp.stacey, I can't download the file you attached. I think it must be d.org blocking .info files. Maybe give it a .txt extension.

I don't see why we have to use a non-core theme for testing.

Note that each test now need to each be run on fresh D6 and D8 installs

I don't really understand this?

ultimike’s picture

FileSize
22.94 KB
4.26 KB

Based on some comments from benjy via IRC, I re-rolled the patch. Changes include:

Renamed $config variable to $theme_config
Properly wrapped comments to be less than 80 characters

-mike

ultimike’s picture

FileSize
22.94 KB
1.84 KB

Re-rolled patch. Changed theme_config to themeConfig.

Thanks,
-mike

ultimike’s picture

FileSize
22.94 KB
1.31 KB

Re-rolled again, mainly because benjy keeps messing with me on IRC.

-mike

ultimike’s picture

FileSize
23.08 KB
1.81 KB

Hey, look! Another patch re-roll - forgot to declare $themeConfig...

-mike

benjy’s picture

Status: Needs review » Reviewed & tested by the community

I've worked with @ultimike tonight on a few bits, hence all the re-rolls. I've done a final review and I think this patch is a good clean-up. It's also going to make testing a bit more realistic as you're likely to end up with a site that resembles your D6 website.

@jp.stacey, I think you were trying to make a few other points that probably shouldn't hold this issue up. Do you want to create a follow-up issue with any further concerns?

Should we document somewhere that if your blocks all end up disabled, enabling a theme with the same name as your D6 theme before or after the migration will pick-up the block configuration?

ultimike’s picture

I added a "Documentation needed" section to #2221805: Manual Testing: D6 Block since we don't have a good place for documentation yet...

-mike

benjy’s picture

Maybe we could add it as a new child page here? https://www.drupal.org/node/2228547

jp.stacey’s picture

Just a quick one as I'm in transit again, so sorry if the following is in any way brusque. The only reason I've held this up is that when I came to it was in "Needs Review". I wanted to review it, but it wasn't clear from either the issue description, or the comments following:

(a) what the work was actually meant to do (this has been clarified a bit as we've gone on) or
(b) what steps were required in order to review it and say "yes, I agree, this works as described"

So I've been trying to clear up both (a) - which is certainly clearer, but you'd have to read the whole comment thread to be sure, and (b), where I've tried to put together a manual test script - a set of "steps to review" that might enable RTBC, but I don't think anyone else is following it. As an example of clarity, see e.g. #2289223: Manual Testing: D6 Menu (which definitely isn't my work as I copied the structure from another ticket.)

My feeling is that from a PM background it still isn't particularly clear how "the community" - as opposed to the developers who've been closely involved in it and already know how it works - is meant to review this issue, nor whether such a review should only ever rely on running some automated test (which again there are no instructions on how to run) or whether it should follow a manual test script.

But given my slow rate of response at the moment I don't particularly want to be the only blocker on this issue, given others seem convinced it works as designed.

(Edited since posting, hopefully for my *own* clarity!)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The change looks good - agree with @jp.stacey that documentation here is important since people might expect migrate to try to enable and set up the default and admin theme - however I think it perfectly reasonable to expect some sort of minimal configuration before migrate runs - and having the default theme and admin theme set and migrating to those choices seems sensible.

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockTheme.php
    @@ -0,0 +1,107 @@
    +      return $d8_default_theme;
    ...
    +      return $d8_admin_theme;
    

    return $this->themeConfig->get(''); then no $d8_* variables which are easy to confuse with the $d6_* variables.

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockTheme.php
    @@ -0,0 +1,107 @@
    +    // Oh well, we tried.
    

    I think this comment could be improved.

benjy’s picture

Status: Needs work » Needs review
FileSize
23 KB
1.32 KB

Re-rolled with the changes from #68.

chx’s picture

Status: Needs review » Reviewed & tested by the community

It was agreed that modules will need to be enabled before you can migrate. It's not unreasonable to say 'everything contrib/custom' needs to be enabled cos what if a theme wants to add / change a migration (like this one)?

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://www.drupal.org/files/issues/2248407-69.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 23550  100 23550    0     0  15915      0  0:00:01  0:00:01 --:--:-- 22154
error: patch failed: core/modules/migrate_drupal/src/Tests/d6/MigrateSystemThemeTest.php:1
error: core/modules/migrate_drupal/src/Tests/d6/MigrateSystemThemeTest.php: patch does not apply
hussainweb’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
22.77 KB
benjy’s picture

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockTheme.php
    @@ -0,0 +1,103 @@
    + * @file
    + * Contains
    

    Missing class comment here.

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockRegion.php
    @@ -0,0 +1,46 @@
    + * @file
    + * Contains
    

    And here.

hussainweb’s picture

FileSize
1.06 KB
22.89 KB

I hope this gets queued for testing as it's already Needs review. I have attached the interdiff too. I took example from other files in the directory and used the completely qualified class name in the file comments.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5032755 and pushed to 8.x. Thanks!

  • alexpott committed 5032755 on 8.x
    Issue #2248407 by ultimike, hussainweb, benjy, jp.stacey: D6 Block...
chx’s picture

Issue summary: View changes

Updated the IS it was woefully outdated. Edit: alexpott committed it.Oh well we need it for archive purposes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.