fix(reader-activation): Content Gate metadata for legacy ESP sync#4742
Conversation
024b907 to
2d87606
Compare
dkoo
left a comment
There was a problem hiding this comment.
Changeset is tiny and clean. However, manual and unit testing fail for a couple of reasons:
🔴 Missing Content_Access_Group field
The failing unit test is because the Content_Access_Group field isn't in the parent release branch yet. This field was added in #4697, which hasn't yet made it to release.
Test_Content_Gate_Legacy::test_legacy_schema_exposes_content_access_fields
Failed asserting that an array has the key 'Content_Access_Group'.
Suggested fix: I opened #4746 to cherry-pick that PR to release as a hotfix. Once that PR lands we can rebase this branch on release to resolve things. Alternatively, you can just cherry-pick that same commit hash 8d71495 to this branch since it's also a hotfix, and then I'll close #4746.
🔴 Unprefixed meta fields get silently dropped before the sync
Unlike Legacy_Basic and Legacy_Payment classes, Content_Gate doesn't normalize its own fields using Legacy_Metadata::normalize_contact_data() before appending its fields, so the Content Access fields get appended without NP_ (or custom) prefix. This causes the fields to be silently dropped from the contact before getting synced to the ESP.
Suggested fix: Normalize all fields, either by adding a handler to prefix Content_Gate fields before returning for a legacy sync, or by moving Legacy_Metadata::normalize_contact_data() outside of the individual Legacy_* classes and to a later point where it can run on all fields collected for a legacy sync but before it gets passed to the sync handler.
dkoo
left a comment
There was a problem hiding this comment.
Additional feedback in inline comments. Also, this doesn't originate in this PR, but the includes/reader-activation/sync/contact-metadata/class-content-gate.php file has incorrect newspack text domains throughout—let's find/replace with newspack-plugin to keep it in line with the rest of the plugin.
|
@dkoo Thanks for the review!
Fixed in f3077f1.
I worked around the CI failure by dropping the assertion (so other fixes could land green). Once #4746 lands on |
dkoo
left a comment
There was a problem hiding this comment.
@miguelpeixe latest changes look good, thanks for the updates! I'll hold off approving until merge conflicts are resolved.
…pdate institution label
f3077f1 to
cf33f4b
Compare
|
@dkoo Rebased onto
54/54 tests in the |
dkoo
left a comment
There was a problem hiding this comment.
Passes manual testing, and I see all three NP_Content Access fields being synced now. A couple of non-blocking nitpicks inline, but nothing urgent.
|
@dkoo Thanks for the approval and the follow-up nits! Text domain fix — Done in 3f29a4f. Find/replaced
|
dkoo
left a comment
There was a problem hiding this comment.
Sounds good! Thanks, @miguelpeixe
|
Hey @miguelpeixe, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
## [6.41.2](v6.41.1...v6.41.2) (2026-05-21) ### Bug Fixes * **reader-activation:** Content Gate metadata for legacy ESP sync ([#4742](#4742)) ([28f543a](28f543a))
|
🎉 This PR is included in version 6.41.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
## [6.41.2](Automattic/newspack-plugin@v6.41.1...v6.41.2) (2026-05-21) ### Bug Fixes * **reader-activation:** Content Gate metadata for legacy ESP sync ([#4742](Automattic/newspack-plugin#4742)) ([66998c2](Automattic/newspack-plugin@66998c2))
|
🎉 This PR is included in version 6.42.0-alpha.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
* **editor:** exclude Customizer Additional CSS from iframed editor ([#4750](Automattic/newspack-plugin#4750)) ([123c507](Automattic/newspack-plugin@123c507)) * **reader-activation:** Content Gate metadata for legacy ESP sync ([#4742](Automattic/newspack-plugin#4742)) ([66998c2](Automattic/newspack-plugin@66998c2)) (cherry picked from commit 8edeec2b01fb32cbfbcd24847cbcc664581160a4)
All Submissions:
Changes proposed in this Pull Request:
The Content Access contact-metadata fields (
NP_Content Access,NP_Content Access Source,NP_Content Access Group) were previously only available to sites running the v1 Reader Activation sync metadata schema. Adopting v1 requires a disruptive cutover that renames/splits most legacy fields and breaks ESP segments built on the old field names.This makes the Content Access fields available on the legacy sync schema as well, so sites can adopt them without the v1 cutover. The fields flow through the existing legacy sync and normalization path with no other behavior changes; field names are unchanged.
Additionally, the Content Access fields are now offered (in both the legacy and v1 schemas) only when the Content Gate feature is enabled (
NEWSPACK_CONTENT_GATES). On sites without the feature, the fields no longer appear in the per-integration field selector and are not synced as permanently-empty values.No backfill of existing ESP contacts is included — existing contacts populate the fields on their next per-contact sync (unchanged limitation).
How to test the changes in this Pull Request:
NEWSPACK_CONTENT_GATESdefined, on the legacy sync schema (default), open the Reader Activation ESP sync field selector and confirm there is no "Content Access" group/fields.define( 'NEWSPACK_CONTENT_GATES', true );inwp-config.php. Reload the field selector and confirm a "Content Access" group now appears with the three fields, on the legacy schema (noNEWSPACK_SYNC_METADATA_VERSION*constant needed).NP_Content Access=Yes(and Source/Group as applicable).NP_Content Access=No.define( 'NEWSPACK_SYNC_METADATA_VERSION_1', true );) to confirm v1 behavior is unchanged aside from the shared feature-flag gating.Other information: