-
Notifications
You must be signed in to change notification settings - Fork 2
[EI-110] Wider edge_integrations_enabled checks #94
Conversation
handle custom headers when we're checking custom headers in other contexts
$geo = Geo\get_geo(); | ||
$interest = Interest\get_interest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use a filter to remove geo or interest such that these will not work correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can filter both things.
https://github.com/pantheon-systems/edge-integrations-wordpress-sdk/blob/main/docs/geo.md#pantheoneiparsed_geo_data
and
https://github.com/pantheon-systems/edge-integrations-wordpress-sdk/blob/main/docs/interest.md#pantheoneiparsed_interest_data
That's actually how the tests are working. However, I would expect if I was filtering either of those that I would be aware that I was potentially breaking/overriding the edge_integrations_enabled
value.
remove_all_filters( 'pantheon.ei.parsed_geo_data' ); | ||
remove_all_filters( 'pantheon.ei.parsed_interest_data' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somewhat related to my question above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, both of those are there to ensure that when testing, we're not inheriting filtered values from other places (since we're not using a real WPUnit environment that clears out the instance in between test runs).
I defer to my initial statement that if you're filtering that stuff, you're modifying the data intentionally, so ymmv, but if there's a place in the documentation that we could be more explicit about the side effects, I'd be happy to update.
The
edge_integrations_enabled
check checks headers sent, but if we aren't sending headers (like we are in the admin) then this will return false.This PR checks returned geo and interest headers first, then checks the headers that are sent (and if they get data back).
In most cases, checking sent headers and their returned responses will not be checked, as we skip it if we have geo or interest headers. However, if custom headers were sent, these will be checked after geo and interest. This is resolved by the addition of a new filter,
pantheon.ei.get_custom_headers
which should be used in a third-party function that returns the custom header data (similar toGeo\get_geo
andInterest\get_interest
) which will hook the third party code intoedge_integrations_enabled
.