Forms: Use JWT for passing the Contact_Form object around - Try 2#44399
Forms: Use JWT for passing the Contact_Form object around - Try 2#44399
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 3 files.
|
Updated unesc_attr to support object values by casting them to arrays before processing. Added a unit test to verify JWT recovery with salesforceData included in the form.
Added logic to convert the jetpackCRM attribute to a boolean if it is a string in Contact_Form. Updated unit test to verify all attribute data, including jetpackCRM, is preserved and correctly restored from JWT.
The JWT::decode method now accepts an $as_array parameter to return the payload as an associative array. Updated contact form code to use this feature, simplifying attribute handling. Added corresponding tests to ensure array decoding works as expected and removed legacy object-to-array conversion logic.
a285170 to
0cff570
Compare
Adjusted the @return annotations in docblocks to indicate that methods may return either an object or an array, improving accuracy and clarity for developers using these methods. Fixes PHP Phan issue
This PR implements #44360 but with fixes that caused us to revert it. Please see the original PR -
The revert can be found here. #44397
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Add a form. Does it submit as expected?
Add a form in a widget. Does it submit as expected?