Problem/Motivation
At the time of this writing, MigrateSqlSource has a getDatabase() method, which tries to build a database connection by pulling information out of its environment and the migration's configuration. This hugely violates best practices (specifically, dependency injection), compromises testability, and introduces a certain amount of brittleness (if the database has been defined incorrectly by the calling code).
Proposed Resolution
Source plugins based on MigrateSqlSource should receive a database connection object in their constructor, or by a setter method.
Remaining Tasks
- Refactor MigrateSqlSource and its entire descendant tree to accept a connection from the calling code
- Review the patch
- Write and test patches for migrate_upgrade and migrate_plus utilizing the new injection.
- Commit and par-tay
API Changes
Some plugins' constructors will change, but no drastic external-facing API changes.
UI Changes
None.
Comments
Comment #2
mikeryanSo, how precisely would this be used by migrate_upgrade/migrate_plus? Relevant related issue: #2548977: How best to persist source database credentials?.
Comment #3
mikeryanComment #4
phenaproximaOne possibility is to use specialized factories:
Comment #6
mikeryanI think this is superceded by the broader #2681869: Provide clean way to merge configuration into migration plugins.