prismicio-community / php-kit

Community maintained development kit for Prismic and the PHP language
https://prismic.io
Other
109 stars 83 forks source link

Fixes an issue where a stale experiment cookie causes an Api 404 #137

Closed gsteel closed 7 years ago

gsteel commented 7 years ago

The experiment cookie value was previously being returned unmodified if found, therefore, users with an experiment cookie for a completed experiment would cause the library to request a ref that did not exist in the API. That was a bad thing.

srenault commented 7 years ago

Hey,

Not sure to understand clearly the issue you're trying to solve. In the case we had an experiment cookie, and the associated experiment becomes completed, the current code performs a request with a non-existing ref. It results in a 404. Ok, but what I don't get is the current code already checks if the ref is valid here: https://github.com/prismicio/php-kit/blob/master/src/Prismic/Api.php#L429

Could you show me what I'm missing?

gsteel commented 7 years ago

The problem, is that if the check for the experiment returns null, which it does if the experiment has ended, then the ref is returned as whatever the cookie value is - in the case of an ended experiment, that cookie value is junk and the API responds appropriately further down the line.

srenault commented 7 years ago

Ok I see! Thanks.

srenault commented 7 years ago

It works fine! Good job.