Problem/Motivation
When Drupal cannot connect to the migration database, migrate_drupal_migration_plugins_alter() adds an error to the messenger service:
Failed to connect to your database server. The server reports the following message: No database connection configured for source plugin variable.
- Is the database server running?
- Does the database exist, and have you entered the correct database name?
- Have you entered the correct username and password?
- Have you entered the correct database hostname?
There are two problems:
- The problem usually has nothing to do with the variable source plugin.
- Adding the error to the messenger service means that it is unpredictable where this error will be displayed.
The same error message is generated by the credential form in migrate_drupal_ui. The first problem applies there, but not the second.
Steps to reproduce
WIth Drush:
- Install Drupal with the Standard profile.
- Enable the
migrate_drupalmodule. - Clear caches:
drush cr. - Check migration status:
drush ms. You will see the error message.
WIth #3063856: Add ability to view migrate_message table data:
- Install Drupal with the Standard profile.
- Enable the
migrate_drupalmodule. - Add test_log.yml to the
migrations/directory of any enabled module. - Execute the
test_logmigration. It should create one migration message. - Clear caches and visit
/admin/reports/migration-messages. You should see the error message.
Proposed resolution
For (1), move the error message reported by the server after the list of suggested remedies.
For (2), find a more reliable way to track errors.
Remaining tasks
User interface changes
Different error messages.
API changes
None
Data model changes
None
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | test_log.yml | 253 bytes | benjifisher |
| #11 | 3198339-11.patch | 2.02 KB | quietone |
| #7 | Screen Shot 2022-06-07 at 9.39.57 AM.png | 176.48 KB | robpowell |
| #4 | 3198339-avoid-printing-database-connection-error-4.patch | 1.5 KB | kiseleva.t |
Comments
Comment #4
kiseleva.t commentedReplaced adding error to Drupal messages by Drupal logger to have that error in logs, also added name of migration to message to make it clear.
Comment #7
robpowellThis worked on 9.3.14, going to rerun tests to see if those failures were a fluke.

Comment #8
robpowellComment #9
mikelutzLooks like this needs more work and tests either way.
Comment #10
mikelutzTest fails seem to be real too, though I'm not sure why this change is causing those particular fails.
Comment #11
quietone commentedDid some debugging and it is failing because the watchdog table does not exist.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.test61444075watchdog' doesn't existBut why did we not get a more useful error message? All I can say it that it gets into what appears to be an infinite loop at this line in the mysql ExceptionHandler.
No interdiff, I only 1 line to MigrationPluginListTest.php
Comment #12
liam morlandI was able to silence the error
No database connection configured for source plugin variable.by adding this tosettings.php:Even without this, Drupal can see the migration data. So, some part of Drupal must be defaulting to the
migratekey even when that is not what is configured to be used.Comment #14
danflanagan8It looks like the latest patch makes both of the changes on the "Proposed Resolution". But per @mikelutz in #9 this still needs tests. Tagging and setting back to NW.
Comment #15
benjifisherPart of the difficulty with this issue is that we do not have good steps to reproduce the problem. We need that before we can write a test.
It is easy with Drush: just enable the
migrate_drupalmodule anddrush cranddrush ms. But we need a way to reproduce the problem with just Drupal core.I previously suggested (in the issue description) using the patch from #3063856: Add ability to view migrate_message table data. In order for that to work, you need to run some migration that creates messages. You could do a full migration from D6 or D7. A more minimal approach is to add the attached migration to
mymodule/migrations/, wheremymoduleis any enabled module. Then execute the migration: it will add one message. I am updating the issue summary to suggest this.Unless someone can think of a better way to test, we may as well postpone this issue on #3063856.
I also tested the current patch from #3312733: SQL migrations cannot be instantiated if database is not available and Node, Migrate Drupal modules are enabled. It did not make any difference.