Problem/Motivation
The current migration to port settings from D7 to D9/10 is:
id: d7_acquia_connector_settings
label: 'Acquia Connector Configurations'
migration_tags:
- Drupal 7
- Configuration
source:
plugin: variable
variables:
- acquia_agent_debug
- acquia_spi_cron_interval
- acquia_spi_cron_interval_override
- acquia_agent_hide_signup_messages
source_module: acquia_agent
process:
debug: acquia_agent_debug
cron_interval: acquia_spi_cron_interval
cron_interval_override: acquia_spi_cron_interval_override
hide_signup_messages: acquia_agent_hide_signup_messages
destination:
plugin: config
config_name: acquia_connector.settings
However, these are no longer in use. There are three (3) new variables which need to be migrated into the state API, they are:
acquia_application_uuid
acquia_identifier
acquia_key
These variables are used in 4.x of the connector (prefixed by acquia_connector instead of acquia).
Steps to reproduce
- Install 7.x-4.6 on Drupal 7 site
- Configure the connector and ensure successful connection
- Install 4.x in a Drupal 10 site alongside the D7 database
- Run d7_acquia_connector_settings migration
The migration will succeed, but effectively does nothing.
Proposed resolution
Change the migration destination to State API with correct mapping values
Remaining tasks
- Change d7_acquia_connector_settings migration to state API
- Change mappings in d7_acquia_connector_settings migration to use new variables
- Test migration
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Comments
Comment #3
wim leersSo was #3204533: Migrate Acquia Connector configurations from Drupal 7 wrong? Or is it just outdated at this point, because the Drupal 7 module has changed in the past ~32 months? 🤔
It seems likely the module has changed since then, because https://www.drupal.org/project/acquia_connector/releases/7.x-4.0 was released in November 2022, but #3204533 happened in 2021. The migration was simply never updated 🙈😬
Looks like we'll need to expand the test coverage/fixture in
MigrateAcquiaConnectorConfigurationTest. See\Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::getModuleSchemaVersion()for how to make version-dependent migrations.Comment #4
dan612 commentedadding static file with patch so it can be applied separately from the MR (in case any changes happen in the MR)
Comment #5
wim leers#4: cool — but did you see #3? 😇
Comment #6
dan612 commentedI did! I'm still not sure what to make of the guidance right now though. Should I be creating an entirely new source plugin which varies the variable names based on the underlying module version? If so, how do we account for this in the migration yaml mapping?
For example in d7_acquia_connector_settings the following variables are mapped:
If I change the variable names coming from the source this mapping is no longer valid. Should I be overriding these values somewhere as well? Perhaps if i create a custom source plugin for this, I also need to make a custom process plugin (to determine correct mapping)... am I overthinking it? 😁 I also had the thought of doing this in an EventSubscriber, but wasn't sure the best way to access the D7 database in a consistent manner (as it wont always be "migrate" in settings.php) ... sorry if i am missing something obvious😬
I was been able to create a source plugin which gets the correct variables based on the module version, like this,
Where getNewMapping() is:
Which works to get the correct variables, but now i have to change the destination to STATE from CONFIG, and alter the prefix...something like
But dont have it all quite fleshed out yet...just wanted to show im still noodling on this 😅
EDIT AFTER A WALK: Why do we even need to try and preserve these old values? If a user is on 7.x-3.x, then the new variables which are needed for D10 Acquia connector to work aren't present in the D7 database anyway...right? I tried to set up the 7.x-3.x version of the module locally and wasn't able to get it to connect to Acquia Cloud to even check out the contents of the variable table. So it would seem that in order for a D7 site to have a functioning Connector Module, it needs to be on Acquia Connector 7.x-4.x at this point.
Comment #7
wim leersIIRC if a migration source plugin's
checkRequirements()throws an exception, that migration is automatically excluded by AM:A. IIRC there's lots of uses of that in themedia_migrationmodule, because that migrates from a LOT of different sources into coremedia.Therefore:
::checkRequirements()… should be enough, because AM:A will automatically eliminate the one that doesn't work
Comment #8
dan612 commentedI did not know about this 😅 - that seems more appropriate than what I was attempting to accomplish...one migration which varies source, process, and destination key+values 🙃. Will give it a go!
Comment #9
wim leersI think I spotted what's wrong 🤓
Comment #10
dan612 commentedOh! Whoopsies, good find 😬 After making these changes I altered the tests a little bit and tried running them. I was met with:
I was able to get around this by implementing the same solution from here - https://www.drupal.org/project/drupal/issues/3197324.
I made a few updates to the MR which i believe also allows it to have a passing test now 😎
Do you mind explaining more about how I might use the minimum_version here? My conditions are:
if >= 7004, run variables to state
if < 7004, run prior config migration
ill need to ponder more about how to accomplish this with annotation based 🫣
Comment #11
dan612 commentedComment #12
dan612 commentedComment #13
dan612 commentedComment #15
dan612 commentedThis patch is failing to apply for me locally for some reason, not sure why. The part which is failing is related to the additions in the test fixture:
Not sure what about this is problematic. The message from patch output is:
The only info i can really glean from that is can't find file to patch at input line 5 - but i have no idea why this would be the case.
Comment #16
wim leersIt's because this patch is patching tests. But Drupal modules' composer packages have their tests (and test fixtures) removed. So in situations like this, you'll want to create a
BLABLABLA-fix-only.patchsubset of the real patch, without those test-related changes.Comment #17
dan612 commentedooooh, ok! i ran this instead ...
git diff origin/4.x -- ':!./tests/*' > ~/Desktop/3416551-change-settings-fix-only.patchand attached that 😄Comment #18
dan612 commented🤔
I think i need the change in the Kernel test in order for this to work 🙃 ....this feels like a 🐥 and 🥚 issue
Comment #20
wim leersYes, the fix-only patch is not supposed to pass tests :D
In July, DrupalCI will stop working, and patches won't be tested. So then the "CI FAILURE RED RED RED" thing will disappear. For now, name patches
WHATEVER-do-not-test.patch, and they won't be tested 👍Tests are passing for the MR, and that's all that matters! 👍
Comment #23
japerryComment #24
nagwani commentedReleased in 4.0.6