Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
If for some reason a db connection cannot be located, there is a fallback on a global default of 'migrate'. But if that doesn't exist, then really nasty errors start spewing from migrate.
$ drush mi --update d6_user_picture_file
Drupal\Core\Database\ConnectionNotDefinedException: The specified database connection is not defined: migrate in [error]
/app/web/core/lib/Drupal/Core/Database/Database.php:361
Stack trace:
#0 /app/web/core/lib/Drupal/Core/Database/Database.php(166): Drupal\Core\Database\Database::openConnection('migrate', 'default')
#1 /app/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php(130): Drupal\Core\Database\Database::getConnection('default', 'migrate')
#2 /app/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php(93): Drupal\migrate\Plugin\migrate\source\SqlBase->setUpDatabase(Array)
#3 /app/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php(138): Drupal\migrate\Plugin\migrate\source\SqlBase->getDatabase()
#4 /app/web/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php(42): Drupal\migrate\Plugin\migrate\source\SqlBase->select('node_type', 't')
#5 /app/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php(148): Drupal\node\Plugin\migrate\source\d6\NodeType->query()
#6 /app/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php(163): Drupal\migrate\Plugin\migrate\source\SqlBase->prepareQuery()
#7 /app/web/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php(90): Drupal\migrate\Plugin\migrate\source\SqlBase->initializeIterator()
#8 /app/web/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(228):
Drupal\node\Plugin\migrate\source\d6\NodeType->initializeIterator()
#9 /app/web/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(270):
Drupal\migrate\Plugin\migrate\source\SourcePluginBase->getIterator()
#10 /app/web/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php(92): Drupal\migrate\Plugin\migrate\source\SourcePluginBase->rewind()
#11 /app/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(100):
Proposed resolution
Figure out a better way to inform the user that an available db connection for sucking in data from a previous version of Drupal doesn't exist.
Comments
Comment #2
mikeryanYes, I was never fond of a builtin global default here. fallback_state_key is also problematic, the getDatabase() and setUpDatabase() logic needs a close look.
Comment #4
mikeryanDealing with this in #2700693: [meta] Make MigratePluginManager::getDefinitions() work cleanly with migrate_drupal enabled and children.