Harden migrations of Recipe 7.x-1.x

Created on 1 October 2021, almost 3 years ago
Updated 18 February 2023, over 1 year ago

Problem/Motivation

Yield_amount and yield_unit fields do not get migrated.
Ingredients need to be migrated to a new module in Drupal 9.

Steps to reproduce

Migrate recipe content from Drupal 7 site to Drupal 9.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India srishtiiee

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States dcam

    When the module is tested on PHP 8.1 the 7.x-1.x migration starts causing one of those cryptic "Uncaught AssertionError: The container was serialized." errors. Since this patch eliminates that migration, I decided to review it finally.

    1. +++ b/modules/ingredient/ingredient.module
      @@ -137,3 +144,80 @@ function ingredient_quantity_from_fraction($ingredient_quantity) {
      +  $node_source_plugin = NULL;
      +  try {
      +    $node_source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_node');
      +  }
      +  catch (PluginNotFoundException $e) {
      +  }
      +  catch (RequirementsException $e) {
      +  }
      +
      +  if (!$node_source_plugin) {
      +    return;
      +  }
      +
      

      Using a trait outside the scope of a class is deprecated. So I'm copying the code from that trait into the try block. I think we can also simplify the logic here and just return if any exception is thrown.

    2. +++ b/modules/ingredient/ingredient.module
      @@ -137,3 +144,80 @@ function ingredient_quantity_from_fraction($ingredient_quantity) {
      +    $migrations[$plugin_id]['migration_tags'][] = 'Recipe node';
      

      I'm slightly concerned about naming collisions here, so I'm making the tag name more specific. It probably doesn't matter at all, but it also won't hurt to tweak it.

    3. +++ b/modules/ingredient/tests/src/Kernel/Migrate/recipe71/MigrateIngredient71Test.php
      @@ -16,7 +16,7 @@ class MigrateIngredient71Test extends MigrateIngredient71TestBase {
      -  protected static $modules = ['ingredient'];
      +  protected static $modules = ['ingredient', 'node'];
      

      I don't understand the reason for this change.

    4. +++ b/modules/ingredient/tests/src/Kernel/Migrate/recipe71/MigrateIngredientSettings71Test.php
      @@ -12,7 +12,7 @@ class MigrateIngredientSettings71Test extends MigrateIngredient71TestBase {
      -  protected static $modules = ['ingredient'];
      +  protected static $modules = ['ingredient', 'node', 'text'];
      
      +++ b/tests/src/Kernel/Migrate/recipe71/MigrateRecipe71Test.php
      @@ -16,6 +16,7 @@ class MigrateRecipe71Test extends MigrateRecipe71TestBase {
      +    'comment',
      

      Or this change.

    5. +++ b/tests/src/Kernel/Migrate/recipe71/MigrateRecipeDisplaySettings71Test.php
      @@ -24,6 +31,7 @@ class MigrateRecipeDisplaySettings71Test extends MigrateRecipe71TestBase {
      +    $this->installSchema('node', 'node_access');
      

      Or this change and the corresponding addition of the node_access table to the fixture.

    6. And I think there might be one other that Dreditor didn't copy in properly.

    Removing those changes didn't cause the tests to fail locally, so I'm taking them out of the patch.

  • 🇺🇸United States dcam

    I missed removing an additional fixture change for the node_access table.

    • dcam committed b9ce2e47 on 8.x-2.x
      Issue #3240263 by srishtiiee, dcam, huzooka, Wim Leers: Harden...
  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States dcam

    Thank you all for your contributions!

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

Production build 0.69.0 2024