Require SDK ^2.0.0-beta.2 and use the PayloadContext enum - #58
Merged
Merged
Conversation
beta.2 of the SDK replaced Parameters::PAYLOAD_CONTEXT_BROWSER with the PayloadContext enum. The bundle used the constant when rendering the fbq() init call, and its ^2.0.0-alpha.3 constraint also matches a beta, so a fresh install resolved to beta.2 and threw an undefined constant Error from an event listener, i.e. a 500 on every page that raises an event with client side tracking enabled. Use PayloadContext::Browser and move the constraint floor to beta.2, the first release that has the enum. beta.1 also accepts a subdomain index above 2, which Meta writes for a cookie set on a deeper domain. Two tests asserted that such a value is rejected; they now use an index with a leading zero, which still is, and a deeper domain is covered as a value that must parse.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #58 +/- ##
=========================================
Coverage 97.95% 97.95%
Complexity 156 156
=========================================
Files 32 32
Lines 489 489
=========================================
Hits 479 479
Misses 10 10
🚀 New features to boost your workflow:
|
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.
Problem
A fresh install of
v1.0.0-alpha.1is broken, and so is any existing install that runscomposer update.v2.0.0-beta.2of the SDK replacedParameters::PAYLOAD_CONTEXT_BROWSERwith thePayloadContextenum. It is called out there as a breaking change within the beta series. The bundle uses that constant in one place,AddEventToTagBagSubscriber, when it renders thefbq('init', …)call.Nothing keeps beta.2 out: the bundle requires
^2.0.0-alpha.3, and the install command in the release notes uses^2.0@alpha. Both match a beta, so Composer resolves to beta.2. The result is an undefined constantErrorthrown from a listener onConversionsApiEventRaised, which propagates into the controller: a 500 on every page that raises an event with client side tracking enabled. Server side only setups are not affected, and neither is an install that stays locked on alpha.3.Found by installing beta.2 on
masterand running the suite: 4 errors, 2 failures, and PHPStan flagging the same line.Change
getPayload(Parameters::PAYLOAD_CONTEXT_BROWSER)becomesgetPayload(PayloadContext::Browser).^2.0.0-beta.2, the first release that has the enum.--prefer-lowestresolves to it.UPGRADE.mdtells consumers to allow^2.0@betarather than@alpha.The two failures were tests, not behaviour.
v2.0.0-beta.1accepts a subdomain index above 2, which is what Meta writes for a cookie set on a deeper domain such asa.b.example.co.uk. Two tests asserted thatfb.3.…is rejected. They now use an index with a leading zero, which beta.2 still rejects (checked, not assumed), andfb.3.…is added as a value that must parse, for both_fbcand_fbp. The bundle benefits from that change without any code of its own.Nothing else in the two betas touches the bundle: it does not subclass
Event, so thegetMapping()signature change does not apply.After merging
This needs a new pre-release of the bundle.
v1.0.0-alpha.1cannot be repaired, since a published tag'scomposer.jsonis fixed, but fixing forward is enough:^1.0@alpharesolves to the newest pre-release, so anyone installing gets the working one.One thing to weigh, because this is the second time in a day an SDK pre-release broke a caret range (alpha.2's exception model was the first): the SDK's notes say its API "may still change", and a caret on a pre-release trusts that it will not. Pinning the SDK exactly until 2.0 is stable would make each bundle release work with precisely what it was tested against, at the cost of a bundle release per SDK pre-release. Not done here; the constraint stays a caret, as before.
Verified on PHP 8.1 and 8.4, with
--prefer-lowestand highest, plus PHPStan, ECS, Rector, the dependency analyser,composer validateandcomposer normalize. 174 tests.