Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add flag to force object #416

Merged
merged 3 commits into from Apr 13, 2022
Merged

fix: add flag to force object #416

merged 3 commits into from Apr 13, 2022

Conversation

bshaffer
Copy link
Collaborator

@bshaffer bshaffer commented Apr 4, 2022

see #413

@mfn
Copy link

mfn commented Apr 5, 2022

Is it possible to add a test for this?

@bshaffer
Copy link
Collaborator Author

@mfn sure can! done. Thanks for not letting me be lazy :)

@bshaffer bshaffer merged commit e67638d into main Apr 13, 2022
@bshaffer bshaffer deleted the force-object-encoding branch April 13, 2022 23:27
@pazzernick
Copy link

I tested it in the field... the change broke existing code that wasn't expecting the payload to be converted to object form! e.g. my final JWT payload should contain some Arrays, and is no use when entirely object form.

My workaround/fix is to comment out this recent change...

Can JSON_FORCE_OBJECT be 'added' only when asked for, perhaps via a global property and method-chaining.

Given that 'json_encode' will create JSON objects, if PHP objects are supplied... I would default to the original code, and only add the JSON_FORCE_OBJECT when explicitly enabled via the new method.

@bshaffer
Copy link
Collaborator Author

I did not consider this edge case.... the problem we were trying to solve was to ensure that an array type (or other types such as int) were not returned from JWT::decode. However, you're right, I think we need to revert this change and go about it a different way...

bshaffer added a commit that referenced this pull request Apr 21, 2022
@bshaffer
Copy link
Collaborator Author

@pazzernick this is now fixed in v6.1.2. Thank you for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants