Problem/Motivation

We need an upgrade path for the D7 core Color module.

Remaining Tasks

Theme-specific variables maintained by the Color module need to be moved into configuration objects. This is a bit tricky, since the variable names are dynamic, but still doable (they follow specific naming patterns). We need a migration for this, with relevant tests. It will also probably be necessary to write a specialized source plugin for this.

Comments

quietone’s picture

Assigned: Unassigned » quietone
quietone’s picture

Status: Active » Needs review
StatusFileSize
new15.36 KB

This patch does migrate the D7 color data but there are two problems that I know of. One is a schema error for the variable 'screenshot' and the other is there is no test for the destination plugin.

For the first problem, the error is 'color.theme.garland:screenshot missing scheme'. It seems the solution is to add the screenshot variable to the schema. If that is true, then that needs to be done use the update process?

For the destination plugin, I'll work on that again tomorrow. In the meantime, I'd like to see how testing goes.

Look Ma, no hash!!!

Status: Needs review » Needs work

The last submitted patch, 2: 2500495-3.patch, failed testing.

The last submitted patch, 2: 2500495-3.patch, failed testing.

quietone’s picture

As expected, fail on 'color.theme.garland:screenshot missing schema'.

quietone’s picture

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new15.64 KB
new9 KB

Talked to phenaproxima on IRC and got this sorted. Thx!

phenaproxima’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -32,7 +32,8 @@
    +        ->condition('name', 'color_%screenshot', 'NOT LIKE');
    

    Should be color_%_screenshot.

  2. +++ b/core/modules/color/src/Tests/Migrate/d7/MigrateColorTest.php
    @@ -70,7 +70,7 @@
    +    $this->assertIdentical(NULL, $config->get('screenshot'));
    

    There's no need for this assertion -- trying to create a screenshot property in the config entity would throw a schema exception, so we'd catch this anyway :)

  3. +++ b/core/modules/color/tests/src/Unit/Plugin/migrate/source/d7/ColorTest.php
    @@ -63,6 +63,15 @@
    +    var_dump($this->databaseContents['variable']);
    

    Should this be here? :)

quietone’s picture

StatusFileSize
new15.53 KB
new1.75 KB

1. Absolutely
2. Yes, of course.
3. Oh my, I need more sleep. Fixed.

Kudos to phenaproxima!

quietone’s picture

Status: Needs work » Needs review
mikeryan’s picture

+++ b/core/modules/color/src/Plugin/migrate/process/d7/Color.php
@@ -0,0 +1,35 @@
+    // Result array is configuration name, configuration sub element and value.

For those of us not already conversant with the color variables, could the comment show by example what's happening? I take it we're taking something like variable color_bartik_palette with value array(stuff), and turning it into array('color.theme.bartik', 'palette', array(stuff))...

Apart from that, looks good, but I'd leave the RTBC to someone who can test this manually and see that they get the desired color settings.

Actually, just had a second thought - should we be checking to be sure the referenced theme exists in D8? If we were to blindly migrate the color settings for a theme that isn't there, and the theme were installed later, would it pick up the migrated values? I'm guessing it'll install its defaults...

phenaproxima’s picture

Status: Needs review » Needs work

Looks perfectly good to me, except for some nits. The most pressing issue, I feel, is the need for comments. Because color configuration is handled so strangely in D7, it can easily be very difficult to follow the migration logic at work here. So comment the hell out of it, I say! :)

  1. +++ b/core/modules/color/src/Plugin/migrate/destination/d7/Color.php
    @@ -0,0 +1,52 @@
    + * Contains  \Drupal\color\Plugin\migrate\destination\d7\color.
    

    Nit: There's an extra space between "Contains" and "\Drupal".

  2. +++ b/core/modules/color/src/Plugin/migrate/destination/d7/Color.php
    @@ -0,0 +1,52 @@
    + * Provides Color destination plugin.
    

    This shouldn't be in the @file comment.

  3. +++ b/core/modules/color/src/Plugin/migrate/destination/d7/Color.php
    @@ -0,0 +1,52 @@
    +      if (isset($value)) {
    +        $config = \Drupal::configFactory()->getEditable($value[0]);
    +        $config->set($value[1], $value[2]);
    +      }
    

    I agree with @mikeryan that a comment here would be nice, explaining what is expected from $row->getRawDestination() and how it is used.

    Also, the config factory should be injected in the constructor (ContainerFactoryPluginInterface).

  4. +++ b/core/modules/color/src/Plugin/migrate/destination/d7/Color.php
    @@ -0,0 +1,52 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function fields(MigrationInterface $migration = NULL) {
    +  }
    

    This needs to be filled in.

  5. +++ b/core/modules/color/src/Plugin/migrate/process/d7/Color.php
    @@ -0,0 +1,35 @@
    +    // Result array is configuration name, configuration sub element and value.
    +    $x = explode('_', $value[0]);
    +    $result[0] = 'color.theme.' . $x[1];
    +    $result[1] = $x[2];
    +    $result[2] = $value[1];
    +    return $result;
    

    Can the comment be a little more extensive? It should explain what the value looks like on the way in, and what we're separating it out into.

  6. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,50 @@
    +  /**
    +   * The variable names to fetch.
    +   *
    +   * @var array
    +   */
    +  protected $variables;
    

    Should be @inheritdoc.

  7. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,50 @@
    +    $query = $this->select('variable', 'v')
    +        ->fields('v', array('name', 'value'))
    +        ->condition('name', 'color_%', 'LIKE')
    +        ->condition('name', 'color_%_screenshot', 'NOT LIKE');
    +    return $query;
    

    Nit: This can all be a single line (return $this->select(...)). No need for a separate return.

  8. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,50 @@
    +    return array(
    +      'name' => $this->t('The name of the variable.'),
    +      'value' => $this->t('The value of the variable.'),
    +    );
    

    These descriptions might be a bit confusing in a UI situation but I think that can slide for now.

  9. +++ b/core/modules/color/src/Tests/Migrate/d7/MigrateColorTest.php
    @@ -0,0 +1,101 @@
    +  public static $modules = ['color'];
    

    Needs @inheritdoc.

  10. +++ b/core/modules/color/tests/src/Unit/Plugin/migrate/source/d7/ColorTest.php
    @@ -0,0 +1,80 @@
    +  ];
    +  protected $expectedResults = [
    

    Nit: Needs a blank line before $expectedResults.

  11. +++ b/core/modules/color/tests/src/Unit/Plugin/migrate/source/d7/ColorTest.php
    @@ -0,0 +1,80 @@
    +      'value' => [
    +        0 => 'public://color/bartik-1d249313/colors.css',
    +      ]
    

    For readability, there's no need to index this array with 0. Just 'value' => ['public://...'] is fine.

  12. +++ b/core/modules/color/tests/src/Unit/Plugin/migrate/source/d7/ColorTest.php
    @@ -0,0 +1,80 @@
    +      'value' => [
    +        0 => 'public://color/bartik-e0e23ad7/logo.png',
    +        1 => 'public://color/bartik-e0e23ad7/colors.css'
    +      ],
    

    Same here.

  13. +++ b/core/modules/color/tests/src/Unit/Plugin/migrate/source/d7/ColorTest.php
    @@ -0,0 +1,80 @@
    +        'value' => [
    +          0 => 'public:://color/bartik-b69cfcec/screenshot.png',
    +        ]
    

    ...and here.

Actually, just had a second thought - should we be checking to be sure the referenced theme exists in D8? If we were to blindly migrate the color settings for a theme that isn't there, and the theme were installed later, would it pick up the migrated values? I'm guessing it'll install its defaults...

Unless it causes exceptions and site breakage, I don't feel strongly about it one way or the other. We can do it if it's easy, but if it's tricky then it seems to me like a lot of work for little gain.

quietone’s picture

@mikeryan and @phenaproxima, thx for the review. I appreciate it, esp as this is a low priority item.

I've addressed all your concerns, and will do some testing in the next few days paying attention to what happens when a theme is installed after a migration.

quietone’s picture

Assigned: quietone » Unassigned
Status: Needs work » Postponed
StatusFileSize
new12.45 KB
new12.45 KB

This and another theme 'variable to config' issue both need and an explode process plugin. And since there was an existing issue just for that, #2575101: Add an explode/separator process plugin I posted a patch there. I rewrote this to use that plugin and I think it is easier to follow now.

Still needs testing as suggested in #11.

And blocked by #2575101: Add an explode/separator process plugin

quietone’s picture

Status: Postponed » Needs work
Issue tags: +Novice

#2575101: Add an explode/separator process plugin is in so no longer postponed.

Actually, just had a second thought - should we be checking to be sure the referenced theme exists in D8? If we were to blindly migrate the color settings for a theme that isn't there, and the theme were installed later, would it pick up the migrated values? I'm guessing it'll install its defaults...

Need to follow up this question from mikeryan's query in #11.

quietone’s picture

Status: Needs work » Needs review

Let's see what the testbot finds.

Status: Needs review » Needs work

The last submitted patch, 14: 2500495-14.patch, failed testing.

quietone’s picture

quietone’s picture

Issue tags: +migrate-d7-d8

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

heddn’s picture

Issue tags: -Novice

Too much time has passed. Removing the novice flag because someone new isn't going to be able to work on any actionable tasks on this issue.

chx’s picture

> core/modules/color/src/Plugin/migrate/destination/d7/Color.php

This shouldn't exist. Destinations are not per D7 they are per D8. So: core/modules/color/src/Plugin/migrate/destination/Color.php .

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

damienmckenna’s picture

Status: Postponed » Needs work

Now that #2575101 has been committed, this can be worked on again.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new12.79 KB

Rerolled.

quietone’s picture

StatusFileSize
new12.79 KB
new490 bytes

Fix namespace error.

The last submitted patch, 26: 2500495-26.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 27: 2500495-27.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new13.51 KB
new1.54 KB

Correct test fails.

phenaproxima’s picture

Assigned: Unassigned » phenaproxima

Self-assigning for review.

phenaproxima’s picture

Status: Needs review » Needs work

All I could find was nitpicky stuff. Everything here looks straightforward and in order. First-class work. Once all this feedback is addressed, this is RTBC. Excellent work, @quietone and @Jo Fitzgerald.

  1. +++ b/core/modules/color/migration_templates/d7_color.yml
    @@ -0,0 +1,37 @@
    +  # build the configuration name from the variable name, i.e.
    

    Nit: Should start with a capital letter.

  2. +++ b/core/modules/color/migration_templates/d7_color.yml
    @@ -0,0 +1,37 @@
    +  # color_themename_element becomes color.theme.themename
    

    The values should be enclosed by single quotes, since they are example values.

  3. +++ b/core/modules/color/migration_templates/d7_color.yml
    @@ -0,0 +1,37 @@
    +      plugin: concat
    +      source:
    +        - constants/config_prefix
    +        -
    

    Um, why is the second source value empty?

  4. +++ b/core/modules/color/src/Plugin/migrate/destination/Color.php
    @@ -0,0 +1,89 @@
    +   *   The plugin definiiton.
    

    "Definition" is misspelled :)

  5. +++ b/core/modules/color/src/Plugin/migrate/destination/Color.php
    @@ -0,0 +1,89 @@
    +      $config = $this->configFactory->getEditable($row->getDestinationProperty('configuration_name'));
    +      $config->set($row->getDestinationProperty('element_name'), $row->getDestinationProperty('value'));
    +      $config->save();
    

    These calls can be chained for readability:

    $this->configFactory->getEditable()->set()->save();

  6. +++ b/core/modules/color/src/Plugin/migrate/destination/Color.php
    @@ -0,0 +1,89 @@
    +      $imported = TRUE;
    

    Why bother to set $imported at all? We could just return TRUE here, and return FALSE by default at the end of the method.

  7. +++ b/core/modules/color/src/Plugin/migrate/destination/Color.php
    @@ -0,0 +1,89 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function fields(MigrationInterface $migration = NULL) {
    +  }
    

    Ermm...this should probably return something? An array, at least?

  8. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,43 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected $variables;
    

    This is never used and should be removed.

  9. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,43 @@
    +      ->fields('v', array('name', 'value'))
    

    Should use [], not array().

  10. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,43 @@
    +    return array(
    +      'name' => $this->t('A color variable for a theme.'),
    +      'value' => $this->t('The value of a color variable.'),
    +    );
    

    Should use [] syntax.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new13.45 KB
new5.48 KB

@phenaproxima, thanks. Fixed all the nits.

About #3, the second item in the array, which appears empty. is the value piped in from the previous plugin. However, it is odd and to avoid further questions about it I have changed the yml to be more explicit. The pipeline is now split into two step, the first getting the 'theme_name' and in the second step '@theme_name' is an input value. That should make it clearer.

phenaproxima’s picture

I think you may have posted the wrong interdiff...?

quietone’s picture

StatusFileSize
new3.22 KB

Fudge. Here is the correct one.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Lookin' damn fine.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -43524,6 +43524,42 @@
+->values(array(
+  'name' => 'color_garland_files',
+  'value' => 'a:19:{i:0;s:50:"public://color/garland-b69cfcec/menu-collapsed.gif";i:1;s:54:"public://color/garland-b69cfcec/menu-collapsed-rtl.gif";i:2;s:49:"public://color/garland-b69cfcec/menu-expanded.gif";i:3;s:45:"public://color/garland-b69cfcec/menu-leaf.gif";i:4;s:67:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/body.png";i:5;s:69:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-bar.png";i:6;s:75:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-bar-white.png";i:7;s:69:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-tab.png";i:8;s:76:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-navigation.png";i:9;s:78:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-content-left.png";i:10;s:79:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-content-right.png";i:11;s:73:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-content.png";i:12;s:81:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-navigation-item.png";i:13;s:87:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/bg-navigation-item-hover.png";i:14;s:77:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/gradient-inner.png";i:15;s:67:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/logo.png";i:16;s:73:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/screenshot.png";i:17;s:41:"public://color/garland-b69cfcec/style.css";i:18;s:45:"public://color/garland-b69cfcec/style-rtl.css";}',
+))
+->values(array(
+  'name' => 'color_garland_logo',
+  'value' => 's:40:"public://color/garland-b69cfcec/logo.png";'
+))
+->values(array(
+  'name' => 'color_garland_palette',
+  'value' => 'a:5:{s:4:"base";s:7:"#d0cb9a";s:4:"link";s:7:"#917803";s:3:"top";s:7:"#efde01";s:6:"bottom";s:7:"#e6fb2d";s:4:"text";s:7:"#494949";}',
+))
+->values(array(
+  'name' => 'color_garland_screenshot',
+  'value' => 's:73:"/var/www/drupal/sites/default/files/color/garland-b69cfcec/screenshot.png";'
+))
+->values(array(
+  'name' => 'color_garland_stylesheets',
+  'value' => 'a:2:{i:0;s:41:"public://color/garland-b69cfcec/style.css";i:1;s:45:"public://color/garland-b69cfcec/style-rtl.css";}',
+))

Is there anything that tests this is not migrated?

There's also an array syntax error...

FILE: ...upal/core/modules/color/src/Plugin/migrate/destination/Color.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 63 | ERROR | [x] Short array syntax must be used to define arrays
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
quietone’s picture

StatusFileSize
new13.45 KB
new7.07 KB

Fixed the short array syntax error.

Is there anything that tests this is not migrated?

No. Why is one needed here? What is the use case?

alexpott’s picture

@quietone because we need to ensure that we don't migrate color settings for themes that don't exist - right?

phenaproxima’s picture

I see no great harm in migrating color information for non-existent themes. I am not versed in the internals of how Color works, but should the theme(s) in question suddenly spring into existence (i.e., ported to D8 by some themer), won't migrating the data ensure that the color information is preserved, much to the developer's delight?

phenaproxima’s picture

Status: Needs review » Needs work

Discussed on IRC with @alexpott and it was decided that we should not be migrating the configuration for themes that don't exist on the destination side. So let's add that filtering and appropriate test coverage. Sorry!

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jofitz’s picture

Assigned: phenaproxima » Unassigned
Status: Needs work » Needs review
StatusFileSize
new12.8 KB

Patch in #38 no longer applies. Re-rolled.

Status: Needs review » Needs work

The last submitted patch, 43: 2500495-43.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new465 bytes
new12.8 KB

Correct test failures.

I'm not sure the best way to filter this migration - are we talking a custom process or is there some way to do this in the yaml?

maxocub’s picture

Assigned: Unassigned » maxocub

Assigning for review.

maxocub’s picture

Assigned: maxocub » Unassigned
Status: Needs review » Needs work

This looks good, but still needs work for two things:

  1. The directory migration_templates should be changed for migrations.
  2. The non-existent themes settings should not be migrated as noted in previous comments. I think one way to achieve that would be in the source plugin, we could get a list of available themes and filter the query whit those.
quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new13.29 KB
new1.55 KB

This should address all the points in #47.

Status: Needs review » Needs work

The last submitted patch, 48: 2500495-48.patch, failed testing. View results

maxocub’s picture

Issue tags: +Needs tests

Thanks @quietone! I think that the issue with active themes is on the destination site, not the source.

One way to do that would be to inject the theme_handler service in the source plugin and use listInfo() method.

We'll also need to test that garland theme settings are not migrated as suggested in #37.

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new15.23 KB
new5.31 KB

@maxocub, thx. Must still be in holiday mode.

This injects the theme_handler in the source plugin to get the themes installed on the destination. The test now installs 5 themes and a test has been added to confirm that garland was not migrated.

There is still a problem with the source plugin test, it fails on $this->assertCount($expected_count, $plugin); in MigrateSourceTestBase. I don't know how to fix the query so that that will work. The query could be changed and a prepareRow added to remove the unwanted rows but doesn't seem the right way to go.

Status: Needs review » Needs work

The last submitted patch, 51: 2500495-51.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new15.48 KB
new1.82 KB

Tried simplifying the query in the source plugin but the source plugin test still fails.

Status: Needs review » Needs work

The last submitted patch, 53: 2500495-53.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Assigned: Unassigned » quietone

Adding to my todo list!

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new16.04 KB
new5.4 KB

Let's try this. Reworked the source plugin query again and updated the tests. This required changes to the migration as well for checking if the theme is installed on the destination and to exclude the screenshot variables.

Status: Needs review » Needs work

The last submitted patch, 57: 2500495-57.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.55 KB
new17.67 KB

Add Configuration tag to the migration and updated the UI tests.

Status: Needs review » Needs work

The last submitted patch, 59: 2500495-59.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new18.69 KB
new843 bytes

Ah, I see the new destination needs to be added to getConfigurationClasses in the test.

quietone’s picture

Assigned: quietone » Unassigned
StatusFileSize
new18.7 KB
new1.01 KB

Fixed a few comments.

maxocub’s picture

Status: Needs review » Needs work

This patch looks quite good, I just found a few points that could be improved.

  1. +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php
    @@ -0,0 +1,102 @@
    +    // Screenshot is ignored and will be skipped in the process pipeline.
    +    if ($name[2] != 'screenshot') {
    +      $row->setSourceProperty('screenshot', TRUE);
    +    }
    
    +++ b/core/modules/color/migrations/d7_color.yml
    @@ -0,0 +1,48 @@
    +  # Skip if the variable name ends in 'screenshot'.
    +  screenshot:
    +    plugin: skip_on_empty
    +    source: screenshot
    +    method: row
    

    I find this code unintuitive. Since we have access to the exploded name in the yml file, we could use a combinaison of static_map & skip_on_empty. I think it might be cleaner and more intuitive :

    screenshot:
      -
        plugin: static_map
        source: '@element_name'
        bypass: true
        map:
          - screenshot: false
      -
        plugin: skip_on_empty
        method: row
    

    Also, we don't test that screenshots are not migrated. In the fixtures, there's a screenshot variable for garland, but those variables are skipped because garland is not installed on the destination. I think we should add a screenshot for bartik in the fixtures and add an assert that it is in fact not migrated.

  2. +++ b/core/modules/color/tests/src/Kernel/Migrate/d7/MigrateColorTest.php
    @@ -0,0 +1,65 @@
    +      'classy',
    +      'seven',
    +      'stable',
    +      'stark',
    

    Do we need to install all those themes since we only test bartik?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new18.72 KB
new4.65 KB

1. OK. implemented your suggestion.
2. True, we probably don't need to install all the themes for the test.

maxocub’s picture

Thanks @quietone!
Could you add a $this->assertNull($config->get('screenshot')); in MigrateColorTest.php though, to make sure they are not migrated and don't cause schema errors?

+++ b/core/modules/color/tests/src/Kernel/Plugin/migrate/source/d7/ColorTest.php
@@ -0,0 +1,129 @@
+      [
+        'name' => 'color_custom_stylesheets',
+        'value' => ['public:://color/custom-beadedff/screenshot.png'],
+      ],
...
+      [
+        'name' => 'color_custom_stylesheets',
+        'value' => ['public:://color/custom-beadedff/screenshot.png'],
+      ],

This is a nit, but since this variable is supposed to be a stylesheet, it should be a CSS file.

maxocub’s picture

Status: Needs review » Needs work

Back to NW to address #65.

quietone’s picture

Sorry, I had intended to add the test that screenshot was not migrated.

Both fixed.

quietone’s picture

Odd. the patch isn't showing in the comment.

quietone’s picture

Well, the fixes for #65 are complete and the patch has passed tests. It, 2500495-67.patch, just isn't showing up in the comment.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

Weird that the files don't show up in comment #67, but they do show up in the IS.
I thinks this is ready, RTBCed.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/color/migrations/d7_color.yml
@@ -0,0 +1,54 @@
+  plugin: d7_color

+++ b/core/modules/color/src/Plugin/migrate/destination/Color.php
@@ -0,0 +1,90 @@
+ *   id = "d7_color"

I think this should be just color since destinations shouldn't be for a specific source. This is a similar comment to #22. Guess this is just a missed legacy of the earlier patches.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new18.8 KB
new881 bytes

Yes, that got missed. Fixed now.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

Tests are green, back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed d25a77e0ec to 8.6.x and 1cc630399e to 8.5.x. Thanks!

Backported to 8.5.x since migrate_drupal is still in beta.

  • alexpott committed d25a77e on 8.6.x
    Issue #2500495 by quietone, Jo Fitzgerald, phenaproxima, maxocub,...

  • alexpott committed 1cc6303 on 8.5.x
    Issue #2500495 by quietone, Jo Fitzgerald, phenaproxima, maxocub,...

Status: Fixed » Closed (fixed)

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