Problem/Motivation

Migrate mail system configuration from Drupal 7 site to Drupal 9 site.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

srishti.bankar created an issue. See original summary.

srishtiiee’s picture

Status: Active » Needs review
StatusFileSize
new8.28 KB
wim leers’s picture

Status: Needs review » Needs work
  1. +++ b/migrations/mail_system_settings.yml
    @@ -0,0 +1,29 @@
    +  defaults/sender:
    
    +++ b/src/Plugin/migrate/process/MailSystemModules.php
    @@ -0,0 +1,42 @@
    +    unset($value['default-system']);
    

    Let's add a comment somewhat like this:

        // The "default-system" key-value pair is not for a module-specific
        // migration, but for the default. This is already handled elsewhere in the
        // migration process pipeline ("defaults/sender" and "defaults/formatter").
    

    … that will help future readers understand why this is happening.

  2. +++ b/migrations/mail_system_settings.yml
    @@ -0,0 +1,29 @@
    +migration_dependencies:
    +  required:
    +    - drupal:filter
    

    This dependency does not seems to make sense? It looks like a module dependency in a module's *.info.yml file (see for example core/modules/editor/editor.info.yml), but that's not the same as a migration plugin's YAML file.

    I think these 3 lines can just be deleted entirely :)

  3. +++ b/src/Plugin/migrate/process/MailSystemModules.php
    @@ -0,0 +1,42 @@
    +      $value['module'] = explode("_", $key);
    ...
    +        $value[$value['module'][0]][$value['module'][1]]['formatter'] = $data;
    

    $value['module'] makes it sound like the assigned value will be a module name (i.e. a string). But it won't be. It's always an array.

    So let's change this to

    [$module, $index] = explode("_", $key);
    

    Then you can simplify

    $value[$value['module'][0]][$value['module'][1]]['formatter'] = $data;
    

    to

    $value[$module][$index]['formatter'] = $data;
    

    Easier to read, right? 😊 Bonus: you can delete the

    unset($value['module']);
    

    at the end as well!

srishtiiee’s picture

Assigned: srishtiiee » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.35 KB
new2.26 KB

Made changes suggested in #3.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Perfect! 👍

berdir’s picture

Status: Reviewed & tested by the community » Fixed

> Perfect! 👍

I'll just believe you on that ;)

Personally, I'm not sure how useful this migration is. these things weren't plugins in D7, there's no guarantee that the plugin ID's are still the same and that you even still want to use the same modules in D8+. Seems like something that you should probably manually reconfigure, but I suppose it doesn't hurt.

Status: Fixed » Closed (fixed)

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

paul_leclerc’s picture

It seems that this patch just adds a new directories structure (/b/..) with copies of the current (8.x-4.4) version files :
- mail_system_settings.yml
- MailSystemModules.php

I'm still getting a migration error which may not be related to mail_system :

[error]  Error: Cannot use string offset as an array in Drupal\mailsystem\Plugin\migrate\process\MailSystemModules->transform() (line 36 of /var/www/html/web/modules/contrib/mailsystem/src/Plugin/migrate/process/MailSystemModules.php) 
.. 
[04-Oct-2022 14:39:41 Europe/Berlin] Error: Cannot use string offset as an array in /var/www/html/web/modules/contrib/mailsystem/src/Plugin/migrate/process/MailSystemModules.php

So this patch can be applied but it just adds useless files as far as I know.

luke.stewart’s picture

I'm also getting that same error.

I'm not sure that adding broken functionality is a great UX?

Inserting some debugging I see that in the transform function in
web/modules/contrib/mailsystem/src/Plugin/migrate/process/MailSystemModules.php

the code expects $value to be a 3xn array i.e. $value[a][b][c] however the error occurs due to it receiving

array (
  'mimemail' => 'MimeMailSystem',
  'update_status_notify' => 'MimeMailSystem',
)

interesting the "index" is NULL in this case?

sandip27’s picture

There is still error with this module during the Migration.

Error: Cannot use string offset as an array in Drupal\mailsystem\Plugin\migrate\process\MailSystemModules->transform() (line 36 of /web/modules/contrib/mailsystem/src/Plugin/migrate/process/MailSystemModules.php).

The code line at Line # 36 of MailSystemModules.php file -
$value[$module][$index]['formatter'] = $data;

Since this issue is closed(fixed) and only maintainers can reopen, so would like this to be attended by the maintainers please and @srishtiiee at Acquia to please fix this broken functionality.

Thanks

venkatesh rajan.j’s picture

StatusFileSize
new125.78 KB

I have applied the patch and this issue is not yet resolved.

joelpittet’s picture

Created a follow-up issue for the reports after the initial commit #3463222: Error: Cannot use string offset as an array in MailSystemModules.php on line 36