Add Migrate support from D7 to D10

Created on 20 September 2023, about 1 year ago
Updated 7 July 2024, 5 months ago

I am trying to migrate Workflow items from Drupal 7 to Drupal 10, using drush, migrate, migrate_upgrade, migrate_drupal, migrate_plus and migrate_tools.

upgrade_d7_workflow , success.
upgrade_d7_workflow_state, success
upgrade_d7_workflow_config_transition, failed (all items)
upgrade_d7_workflow_transition, error message below.

Now if I am trying to display transitions page on D10 website, I get wsod (same error in Drupal log messages).

Should I first migrate nodes related to these workflow states?
Is there any patch to handle this error?
Or maybe I need to migrate things in a different order?

Thanks for any tip here.

EDIT (25-09-23)
The first issue linked to the error below is fixed (see comment #3).
But I still can't migrate my workflow configuration (neither nodes using this workflow).
See comment #10 🐛 Migrate support from D7 to D10 Active to see where I stand now.
I guess the process is blocked by this : upgrade_d7_workflow_config_transition:roles:migration_lookup: flatten: Input should be an array or an object, instead it was of type 'NULL'
No transition configuration can be migrated (all failed).

[error]  Error: Call to undefined method Drupal\migrate\Plugin\migrate\id_map\Sql::lookupDestinationId() in workflow_migrate_upgrade_d7_workflow_transition_prepare_row() (line 35 of /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc) #0 [internal function]: workflow_migrate_upgrade_d7_workflow_transition_prepare_row()
#1 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
(...)
Error: Call to undefined method Drupal\migrate\Plugin\migrate\id_map\Sql::lookupDestinationId() in /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc on line 35 #0 [internal function]: workflow_migrate_upgrade_d7_workflow_transition_prepare_row()
#1 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
(...)
Error: Call to undefined method Drupal\migrate\Plugin\migrate\id_map\Sql::lookupDestinationId() in workflow_migrate_upgrade_d7_workflow_transition_prepare_row() (line 35 of /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc).
 [warning] Drush command terminated abnormally.
💬 Support request
Status

Active

Version

1.7

Component

Code

Created by

🇫🇷France Toki Caen, Normandy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Toki
  • 🇫🇷France Toki Caen, Normandy
  • Status changed to Needs review about 1 year ago
  • 🇳🇱Netherlands johnv

    Please try the attached patch.
    There is a change record MigrateIdMapInterface::lookupDestinationId() deprecated

  • 🇫🇷France Toki Caen, Normandy

    Thanks for the quick answer.
    I can't find that patch this morning.
    I have just tried it but unfortunately a new error appears :

     [error]  Error: Class "WorkflowState" not found in workflow_migrate_upgrade_d7_workflow_transition_prepare_row() (line 39 of /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc) #0 [internal function]: workflow_migrate_upgrade_d7_workflow_transition_prepare_row()
    #1 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
    (...)
    #28 {main}. 
    Error: Class "WorkflowState" not found in /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc on line 39 #0 [internal function]: workflow_migrate_upgrade_d7_workflow_transition_prepare_row()
    #1 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
    (...)
    #28 {main}
    Error: Class "WorkflowState" not found in workflow_migrate_upgrade_d7_workflow_transition_prepare_row() (line 39 of /home/my_d10_website/public_html/my_d10_website_root/web/modules/contrib/workflow/workflow.migrate.inc).
     [warning] Drush command terminated abnormally.
    
  • 🇫🇷France Toki Caen, Normandy

    Here si the message in Migrate Tools UI for each new fail for upgrade_d7_workflow_config_transition :

    upgrade_d7_workflow_config_transition:roles:migration_lookup: flatten: Input should be an array or an object, instead it was of type 'NULL'
    
  • 🇫🇷France Toki Caen, Normandy
  • 🇳🇱Netherlands johnv

    Regarding #4. I hope you found the attached a patch in #3. Perhaps you must apply it manually.

  • 🇳🇱Netherlands johnv

    Regarding your error in #4.

    I find it strage that you report line 39.
    my actual workflow.migrate.inc is like this:

    08 use Drupal\workflow\Entity\WorkflowState;
    ...
    39     // Set source and target lookups.
    40      $sid2wid[$row->getSourceProperty('old_sid')] =
    41      $sid2wid[$sid] = WorkflowState::load($new_sid)->getWorkflowId();
    ...

    So, I would expect an error in line 41.
    as a testing alternative, please replace WorkflowState in line 41 with "Drupal\workflow\Entity\WorkflowState" or "\Drupal\workflow\Entity\WorkflowState" (preceding backward slash.)

    I guess, i cannot help with the related issue?

  • 🇫🇷France Toki Caen, Normandy

    Thanks for your time.

    Yesterday, I have applied the patch in #3 manually and the original error message has disappeared, leading to the second one in #4.

    I have just checked "my" workflow.migrate.inc file and surprisingly there is no use statement line 8 (that explains the line 39/line 41 difference).
    Let me go back to you after a new test.

    I added the related issue because there was some similarity with this issue but if it does not help I can delete it from here.

  • 🇫🇷France Toki Caen, Normandy

    Sorry but still an issue.

    upgrade_d7_workflow : no problem, my workflow named "manuscrit" is imported from D7 to D10.

    upgrade_d7_workflow_state : 12 states are imported but from here if I try to open /admin/config/workflow/workflow/manuscrit/transition_roles I get a wsod with this error in the log :

    Drupal\Core\Entity\EntityStorageException: 'workflow_config_transition' entity with ID 'manuscrit_creation' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 519 of /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

    then, I have tried upgrade_d7_workflow_config_transition : 44 failed with this error for each in Migrate Tools UI :

    upgrade_d7_workflow_config_transition:roles:migration_lookup: flatten: Input should be an array or an object, instead it was of type 'NULL'
    

    finally, tried upgrade_d7_workflow_transition (with both patch #3 and modification #8) :

    [warning] array_flip(): Can only flip string and integer values, entry skipped EntityStorageBase.php:278
     [warning] Array to string conversion EntityStorageBase.php:142
     [error]  TypeError: Illegal offset type in Drupal\Core\Entity\EntityStorageBase->load() (line 263 of /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php) #0 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityBase.php(488): Drupal\Core\Entity\EntityStorageBase->load()
    (...)
    TypeError: Illegal offset type in /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php on line 263 #0 /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityBase.php(488): Drupal\Core\Entity\EntityStorageBase->load()
    (...)
    TypeError: Illegal offset type in Drupal\Core\Entity\EntityStorageBase->load() (line 263 of /home/my_d10_website/public_html/my_d10_website_root/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php).
     [warning] Drush command terminated abnormally.
  • 🇫🇷France Toki Caen, Normandy

    Just one more precision, users and user roles have been imported first, of course.

    Concerning the error linked to upgrade_d7_workflow_config_transition (with NULL values apparently), I have also checked the workflow_transitions on source site (d7) and I have data, notably in roles column (see capture).

  • 🇫🇷France Toki Caen, Normandy

    Any idea?
    Could it be the new states machine name patterns?
    If I am correct now it is workflow_name_state_name so my first default state went from creation to manuscrit_creation.
    And if I try to enter manually my D7 states, machine names are automatically created and untouchable.

  • 🇫🇷France Toki Caen, Normandy

    If it's OK with you johnv, I change the status to Active.

  • Status changed to Active about 1 year ago
  • 🇫🇷France Toki Caen, Normandy
  • 🇫🇷France Toki Caen, Normandy
  • 🇫🇷France Toki Caen, Normandy
  • 🇫🇷France Toki Caen, Normandy
  • 🇳🇱Netherlands johnv

    I am sorry I cannot help you further.
    I can point you to the plugins, like: workflow\src\Plugin\migrate\source\d7\WorkflowConfigTransition.php
    (here, the tid is defined as an integer)

    and to the definitions, like: \workflow\migrations\d7_workflow_config_transition.yml

    When, in your database, you check the 'config' table, do you correctly see all states and transitions? When building a workflow via UI, the transitions are created automatically.
    Also, I remember, that a setting is introduced to yes/no create the required 'creation' state.

  • 🇫🇷France Toki Caen, Normandy

    Thanks for your time anyway.

    Indeed, I have tried to understand where something goes wrong in both WorkflowConfigTransition.php or d7_workflow_config_transition.yml.
    I will continue to look for the error in my case.

    After upgrade_d7_workflow, upgrade_d7_workflow_state and failed upgrade_d7_workflow_config_transition, workflow and its states are in config table but only one transition (xxxx_creation) appears.

    In D10 UI, I can't see any settings on creation state when adding new workflow? Only label, permissions, form settings and watchdog.

    I am pretty confident someone has already managed to migrate workflow configuration from Drupal 7 to Drupal 10, so please if you are this person, feel free to share your experience :)

  • 🇫🇷France Toki Caen, Normandy
  • 🇫🇷France Toki Caen, Normandy

    Digging further into the files triggered by upgrade_d7_workflow_config_transition, I traced back to the d7_user_role.yml file where the permissions associated with each role are retrieved in the role_permission (D7) table.
    However, from the first line of this table, the permission is linked to a module (biblio) which is no longer available on Drupal 10 and which has been replaced by another with a different machine name (bibcite).
    It is therefore very likely that the process will fail because of this.
    I traced the problem to this thread (see related issue).
    Roles in D10 site are already set and the permissions will probably evolve and be managed manually.
    Would it be possible to simply modify the d7_workflow_config_transition.yml file so as not to trigger d7_user_role and thus unlock the situation?

  • 🇳🇱Netherlands johnv

    First, another thought.
    Workflow::createState() has a $save=Y/N parameter, which tells the system to yes/no save a state. I guess in the migrate situation, NO status must be created, since it is imported later on.

  • 🇳🇱Netherlands johnv

    Please try to modify the yml files.
    Please check the other 'migrate' issues. There might be a hint.

  • 🇳🇱Netherlands johnv

    The error is fixed.

    • johnv committed 0fe321a4 on 8.x-1.x
      Issue #3388491: Error when migrate from D7 to D10
      
  • 🇫🇷France Toki Caen, Normandy

    While visiting the Drupal Slack migration group, I came across another user who recently was also unable to recover his Workflow between D7 and D10. After a week of research and testing, I finally gave up on the idea of recovering my Workflow configuration. So I finally used the excellent Migrate Skip Fields module and deleted my Workflow field on the target site. The migration process for the nodes associated with the workflow was unblocked and I was able to recover them. Now I'm going to edit these nodes with a new fresh workflow and some SQL or Views Bulk Operations queries.

  • 🇮🇷Iran nick2006

    The website encountered an unexpected error. Try again later.

    Drupal\migrate\Audit\AuditException: Cannot audit migration d7_workflow: Destination does not implement Drupal\migrate\Audit\HighestIdInterface in Drupal\migrate\Audit\IdAuditor->audit() (line 31 of core\modules\migrate\src\Audit\IdAuditor.php).

    Any idea?

  • 🇮🇷Iran nick2006

    With audit set to 'false', workflow tables are not migrated

Production build 0.71.5 2024