Problem/Motivation

A test in Commerce Migrate that checks the migration states is failing with

1) Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ValidateMigrationStateTest::testMigrationState
sort() expects parameter 1 to be array, null given

It happens here where on <code>sort($declared[MigrationState::NOT_FINISHED])

because sort($declared[MigrationState::NOT_FINISHED]) is NULL.

I have a memory of intending to fix that when I wrote the test trait, ValidateMigrationStateTestTrait.php, and obviously forgot to.

Steps to reproduce

Proposed resolution

Set a default for the two arrays in $declared to [].

     $declared[MigrationState::FINISHED] = [];
    $declared[MigrationState::NOT_FINISHED] = [];

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs review
FileSize
818 bytes
quietone’s picture

Title: ValidateMigrationStateTestTrait » Avoid error from sort in ValidateMigrationStateTestTrait
quietone’s picture

Issue tags: +Bug Smash Initiative
quietone’s picture

Issue summary: View changes
mparker17’s picture

Status: Needs review » Reviewed & tested by the community

I've been adding D7 (and D6) migrations for a bunch of contrib modules on a site I need to migrate to D8, and I've been running into this issue - see https://www.drupal.org/pift-ci-job/1979943 for example.

I'd really like to see this get in, and backported to D9.1, D9.0, and D8.9 as well.

I can confirm this patch fixes my tests. Boldly marking as RTBC. Thanks @quietone!

quietone’s picture

@mparker17, thanks.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/migrate_drupal/tests/src/Traits/ValidateMigrationStateTestTrait.php
@@ -91,6 +91,9 @@ public function testMigrationState() {
     $declared = [];
+    $declared = [];

it looks like we declare declared twice?

quietone’s picture

Oh fudge, silly me.

mparker17’s picture

Status: Needs review » Reviewed & tested by the community

Re-RTBC! :D

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: 3204461-9.patch, failed testing. View results

catch’s picture

Status: Needs work » Reviewed & tested by the community

Restoring status after HEAD was broken.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.17 KB
1.08 KB

I went to commit this, but after looking at the patch applied locally (with more context than the patch here shows) I think we can optimise this even more.

Rather than send it back for those changes, I just made them locally.

Does this look good to you @quietone @mparker17?

I realise 14 comments and multiple patches is a lot of churn for such a small change, but as the saying goes, its Drupal, if it's worth doing, it's worth overdoing.

quietone’s picture

I applied the patch locally and immediately said to myself "Oh, that looks better!". This is a nice improvement and it fixes the problem stated in the IS. RTBC +1.

Now do I set it back to RTBC or not? Let's wait awhile and see if someone else chimes in.

  • larowlan committed 43eafc2 on 9.2.x
    Issue #3204461 by quietone, larowlan: Avoid error from sort in...
  • larowlan committed 40dabff on 9.3.x
    Issue #3204461 by quietone, larowlan: Avoid error from sort in...
larowlan’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Needs review » Fixed

Because this is such a trivial patch, and my change was accepted by quietone, I'm going to go outside the normal process and commit this instead of holding it up longer. I've already pushed back twice on a one line patch.

I ummed and ahhed about just fixing it without a patch and saying 'fixed on commit' like we do for obvious coding-standards issues. But felt it was better to put up a patch and get a +1 from quietone.

Committed 40dabff and pushed to 9.3.x. Thanks!

Backported to 9.2.x

quietone’s picture

@larowlan, thank you.

mparker17’s picture

@larowlan, @quietone, thank you both! :D

Status: Fixed » Closed (fixed)

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