Problem/Motivation

Unable to run drush migrate-status, drush migrate-import, etc. on drush 8.0.2 due to error:

Argument 1 passed to Drupal\migrate\Plugin\migrate\source\SqlBase::setUpDatabase() must be of the type array, null given, called in                   [error]
/xxx/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php on line 93 and
defined SqlBase.php:116
Drush command terminated abnormally due to an unrecoverable error.                                                                                    [error]

Drush 8.0.2 has started to trap error E_RECOVERABLE_ERROR and was not present in 8.0.1 where the commands work. Ref: https://github.com/drush-ops/drush/commit/a0e1f70c4e5b1c897f2952624da93c...

When database_state_key is set in the migration config, but does not exist in state (not sure if it should be/how it gets there), NULL is passed to SqlBase::setUpDatabase() but should be an array.

Relevant part from migrate config:

source:
  plugin: d6_file
  database_state_key: migrate_upgrade_6

Proposed resolution

Workaround:

./vendor/bin/drush --halt-on-error=0 migrate-status

To fix, an empty array should be passed instead of NULL if $this->state->get() fails.

Remaining tasks

Test to be written.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andyrigby created an issue. See original summary.

andyrigby’s picture

nitro-hrishi’s picture

Status: Active » Needs review
Issue tags: +drupalconasia2016

Moved to needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

We should have a test for this situation.

+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -89,7 +89,12 @@ public function getDatabase() {
+            array()

Let's use short array syntax [].

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

iMiksu’s picture

Now, using short array syntax [].

heddn’s picture

Closing #2736789: Default of 'migration' database key is ONLY thing that works as duplicate.

+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -84,7 +84,12 @@ public function getDatabase() {
+        $this->database = $this->setUpDatabase(

Let's break that long thing into a separate line to make it more readable.

heddn’s picture

And really, rather than passing an empty array, we should be falling through to the next conditionals. (In my opinion.) Or throwing loud errors that state is in a bad state (pun intended).

heddn’s picture

Status: Needs work » Closed (duplicate)

Per conversation in IRC, closing as duplicate to #2700693: [meta] Make MigratePluginManager::getDefinitions() work cleanly with migrate_drupal enabled. This will be fixed as a result of work in that issue.