Repository navigation
Fix GDPR Cookie Compliance importer: integrations were not saved on a real site - #19
Merged
Merged
Conversation
…iration
- Flag integrations whose source category (2 analytics / 3 marketing)
differs from the category FrontConsent derives from the type, instead of
changing it silently.
- Treat a non-scalar `{slug}_id` as a missing ID (no "Array to string" warning).
- Accept `gdin_values` already decoded as an array.
- Report a negative or non-numeric consent expiration instead of importing
absint() of it.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The settings form sanitizer registered via register_setting() runs on every update_option() and only keeps `cookie_notice_tracking_integrations` when it arrives through its own form fields, so the integrations built by the importer were silently discarded on a real site (the report said "Imported" but nothing was stored). run() now saves through a guard the sanitizer honours, since build() already sanitized every value. Also treat blank saved values (empty texts, no policy page) as unset, so a site that already saved the settings form once still gets banner texts imported. Adds a regression test that registers the setting like admin_init does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
davidperezgar
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #17 (issue #14, already merged). Found while verifying the importer on
main(v1.0.2), first with the test suite and then on a real Local site.The main bug
Imported tracking integrations were never saved. The import report said "Imported: GA4 / GTM", but
cookie_notice_tracking_integrationsstayed empty and the frontend loaded nothing.register_setting(), runs on everyupdate_option()call. It only keepscookie_notice_tracking_integrationswhen it arrives through the form's own fields (cookie_notice_tracking_integration_code/cookie_notice_tracking_remove). The importer sends the key directly, so the sanitizer discarded it and kept the old value.admin_init, which the unit tests never run.run()now saves through a guard (GDPR_Cookie_Compliance_Migration::is_saving()) thatSettings::sanitize_settings()honours. This is safe becausebuild()already sanitizes every value.test_run_persists_integrations_through_the_settings_sanitizerregisters the setting asadmin_initdoes, runs the import twice, and checks that nothing is lost or duplicated.Other fixes
analytics), so a GTM that was3becameanalyticssilently. It is still imported, but it is now reported as needs review with a note. Storing a category per integration would change the data model and the PRO add-on, so that is out of scope here.'',0,null) are now treated as unset and filled. Real choices are still never overwritten.{slug}_id(corrupted data) no longer triggers an "Array to string conversion" warning. It is treated as a missing ID and flagged for review.gdin_valuesalready decoded as an array is now imported instead of being ignored without a report.moove_gdpr_consent_expirationis reported and not imported. Before,absint( -5 )imported 5 days.Tests
gdin_values, negative/invalid expiration, and valid/capped expiration.test_ga4_and_gtm_are_migratednow uses GTM category2, because category3is now flagged on purpose.Verification
Run locally on PHP 8.2:
composer lint: passcomposer phpstan: no errorscomposer test: 115 tests, all passing (108 before + 7 new)Also tested end to end on a Local site that already had FrontConsent configured, using real admin HTTP requests with a temporary admin session:
<script>tag is printed before consent.The site was restored to its previous state afterwards.
Not covered
🤖 Generated with Claude Code