Problem/Motivation

Drupal 7 Migration missing for global settings.

Proposed resolution

Add migration.

Issue fork scheduler-3238953

Command icon 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

omkar.podey created an issue. See original summary.

omkar.podey’s picture

omkar.podey’s picture

omkar.podey’s picture

StatusFileSize
new3.8 KB
new2.38 KB

Corrected Kernel test and fixtures for migrating configuration.

narendrar’s picture

Status: Active » Needs review
huzooka’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
StatusFileSize
new4.19 KB
new398 bytes

Trying make DrupalCI execute kernel tests.

huzooka’s picture

Status: Needs review » Needs work

#4: Excellent work! Some nits but nothing major:

  1. +++ b/migrations/d7_scheduler_settings.yml
    @@ -0,0 +1,18 @@
    +  allow_date_only: scheduler_allow_date_only
    

    Drupal 7 Scheduler does not set a default value for scheduler_allow_date_only on install. This variable is only saved in the database if the config form is submitted. This means that the scheduler_allow_date_only variable might be completely missing in Drupal 7.

    If we search in Drupal 7 Scheduler's codebase for the variable_get('scheduler_allow_date_only' expression, we can see that the logical default value is FALSE.

    If we use the default_value process plugin, we can handle this edge case as well:

    process:
      [...]
      allow_date_only:
        plugin: default_value
        default_value: false
        source: scheduler_allow_date_only
      [...]
    
  2. +++ b/migrations/d7_scheduler_settings.yml
    @@ -0,0 +1,18 @@
    +  default_time: scheduler_default_time
    

    Same situation as above: Based on the results of a very similar search (for variable_get('scheduler_default_time'), the logical default value is '00:00:00', please use

    process:
      [...]
      default_time:
        plugin: default_value
        default_value: '00:00:00'
        source: scheduler_default_time
      [...]
    
  3. +++ b/tests/fixtures/drupal7.php
    @@ -0,0 +1,49 @@
    +/**
    + * @file
    + */
    

    A file comment is missing from here. Something like this would be perfectly adequate:

    /**
     * @file
     * DB fixture for scheduler migration tests on top of core's fixture.
     */
    
  4. +++ b/tests/src/Kernel/MigrateSchedulerTest.php
    @@ -0,0 +1,58 @@
    + * Migrates scheduler configuration.
    

    Change this to "Tests the migration of Drupal 7 scheduler configuration."

  5. +++ b/tests/src/Kernel/MigrateSchedulerTest.php
    @@ -0,0 +1,58 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected static $modules = [
    

    The test on Drupal core 8.9.x fails because of this property. Since Scheduler tries to be compatible with Drupal 8.9.x, this property's visibility should be public (because core 8.9.x requires that this $modules property is public in Kernel tests). Obviously this will trigger a deprecation notice on Drupal core 9+, but it is better than being unable to execute the test on Drupal core 8.9.x (which is still supported!).

  6. +++ b/tests/src/Kernel/MigrateSchedulerTest.php
    @@ -0,0 +1,58 @@
    +  /**
    +   * Tests the migration.
    +   */
    +  public function testMigration() {
    

    The method's comment should say "Tests the migration of scheduler settings.", and I would also change the name of the method to something more specific, like "testConfigurationMigration".

Don't forget to include the drupalci.yml change I added in #6! Otherwise, the kernel test isn't run by DrupalCI.

omkar.podey’s picture

omkar.podey’s picture

Status: Needs work » Needs review

Required changes , Done

huzooka’s picture

Status: Needs review » Reviewed & tested by the community

#9 addresses everything from #7.

RTBC.

Great work!

jonathan1055’s picture

Title: Migration missing for global settings » Add migration of global settings from Drupal 7 to 8
Version: 8.x-1.x-dev » 2.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review

Thank you @omkar.podey and @huzooka this is a good addition.

New features now need to be added to the 2.x branch so I have changed the issue version. However it should all work the same, apart from the patch may need to be re-rolled for drupalci.yml

jonathan1055’s picture

Actually, it would make sense if I committed the change to drupalci.yml to run PHPUnit-Kernel tests. Then neither this issue nor #3249050: Add migration of per-nodetype settings from Drupal 7 to 8/9 would have to add it.

jonathan1055’s picture

StatusFileSize
new4.58 KB

New patch to test at 2.x. Same as #8 except for drupalci.yml

jonathan1055’s picture

I have pushed patch #8 / #13 to the Merge Request branch at 2.x
Not done any local testing yet or made any other changes.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Yep, I expect this to behave identically in both versions — based on #3224263: Plan for Scheduler 2.0 release these global settings won't change 👍

jonathan1055’s picture

I am having some difficulty testing this locally. I am trying to export from D7 into D8 but the first problem is that the Migrate module does not appear to have been upgraded to support MySQL 8 with the new protected/reserved words. select from system fails and requires the table name to be escaped, or enclosed in back-slashes. I thought this was all taken care of in a core fix some time ago in #2966523: MySQL 8 Support

I have hacked core/modules/migrate_drupal/src/MigrationConfigurationTrait.php to change

     // Drupal 5/6/7 can be detected by the schema_version in the system table.
-    if ($connection->schema()->tableExists('system')) {
+    if ($connection->schema()->tableExists('`system`')) {
       try {
         $version_string = $connection
-          ->query('SELECT schema_version FROM {system} WHERE name = :module', [':module' => 'system'])
+          ->query('SELECT schema_version FROM {`system`} WHERE name = :module', [':module' => 'system'])
           ->fetchField();

With this change, the first form validates ok and there are no errors, but I just get sent back to the first page "preparation steps". According to the documentation upgrading-drupal/upgrade-using-web-browser there should be a list of modules that will and will not be imported.

jonathan1055’s picture

I have checked all the other global settings and the only other one in D7 which has a comparable setting in D8 is relating to the time entry. In D8 we have hide_seconds which can be true or false. In D7 we have the configurable time format, which is not available in D8, however, if the D7 time format does not contain 's' for seconds, then it would be nice to set D8 hide_seconds to TRUE. Maybe that logic can be added in to the custom hooks in #3249050: Add migration of per-nodetype settings from Drupal 7 to 8/9 ?

  • jonathan1055 committed ccea839 on 2.x
    Issue #3238953 by jonathan1055, omkar.podey, huzooka: Add migration of...
jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @omkar.podey, @huzooka, @Wim Leers and @narendraR
Merged and fixed.

  • jonathan1055 committed 18a5d54 on 2.x
    Issue #3238953 by jonathan1055: Add D8/9 hide_seconds migration setting...
jonathan1055’s picture

I added a custom migration plugin to set hide_seconds depending on whether 's' is contained in the source scheduler_date_format, and expanded the test to show it works.

Status: Fixed » Closed (fixed)

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