Problem/Motivation
In some specific circumstances, the schema update hook for google_tag.container.*.yml entries will fail with errors such as:
Drupal\google_tag\Migration\GoogleTagMigrateBase::getRequestPathCondition(): Argument #1 ($request_paths) must be of type string, null given, called in /var/www/html/docroot/modules/contrib/google_tag/src/Migration/GoogleTagUpgradeManager.php on line 126
Drupal\google_tag\Migration\GoogleTagMigrateBase::getUserRoleCondition(): Argument #1 ($roles) must be of type array, null given, called in /var/www/html/docroot/modules/contrib/google_tag/src/Migration/GoogleTagUpgradeManager.php on line 145
Steps to reproduce
The observed instance was a D9 production database "dragged" to staging environment in Acquia. As Acquia executes a drush config:import as a post DB copy step, config import was executed before DB updates. (This seems incorrect ... but that's how the config got into this state.)
At this point, the google_tag.container.xxx.yml configurations were loaded in the site, but some values were not populated, and Config API will return a null when they are queried.
When GoogleTagUpgradeManager executes, the following lines will determine that the values are not "" or null, and attempt to treat them as valid values. Replacing each of these checks with a less exact constraint allows the upgrader to handle them correctly.
Proposed resolution
Modify those checks so that the configurations don't get the update applied if they do not have the values set.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | google_tag-db_update_unset_values-3388487-6.patch | 2.41 KB | primsi |
| #6 | google_tag-db_update_unset_values-3388487-6.interdiff.txt | 691 bytes | primsi |
| #2 | google_tag-3388487-db_update_unset_values.patch | 1.98 KB | xurizaemon |
Issue fork google_tag-3388487
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xurizaemonComment #3
xurizaemonComment #4
tritof commentedHi,
I have successfully apply the patch in #2
Drupal 10.1.5 / PHP 8.1
Comment #5
richarddavies commentedI encountered the following error when attempting to upgrade from v1.6 to v2.0.2
Although this patch allowed me to run the database update without error, it does not appear to have correctly/fully migrated my previous container settings. For example, here is my previous container YAML:
And here is the new YAML:
As you can see, it didn't transfer the container ID, environment, or path exclusion settings.
Comment #6
primsi commentedRerolled the patch and added fix for a similar issue in
GoogleAnalyticsMigrator. Haven't checked the issue from #5.Comment #8
rajeshreeputra@RichardDavies I am unable to see the issue described in #5. following step I took to verify:
Let me know if I am missing something.
Comment #9
berliner commentedI have run into this on a D10 site. Though I don't have time to look into exactly how this issue got triggered, I can confirm that the patch addresses the problem and makes the error go away.
Comment #10
falco010Also got the following error when upgrading from 1.8.0 to 2.0.8:
Can confirm that patch #6 solved the errors
Comment #13
japerryConfirmed the bug on 2.0.x. It happens when `drush config:import` runs before `drush updatedb` on a site with 1.x data. The import saves the containers through the 2.x entity class, which strips the 1.x keys, so google_tag_update_8201 gets NULLs. That's why a plain 1.x to 2.x updb doesn't reproduce it.
Patch #6 stops the crash, but as #5 showed, the container still ends up with `tag_container_ids: [null]` and GTM settings under an empty ID. MR !155 replaces it:
If you've hit this, re-enter the container's tag ID and settings. To avoid it, run database updates before config import (`drush deploy` does it in the right order).