-
Notifications
You must be signed in to change notification settings - Fork 846
Correctly validate on/off values for the boolean type in REST API #14240
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
Conversation
This is an automated check which relies on |
Part of me wonders if it wouldn't be best to have that always return boolean values instead of @zinigor What's your take on this? |
|
I agree with @jeherve that I'd rather not use Off the top of my head, we could probably filter on a |
I also agree that it's better to use real boolean values. However, in my mind, there are at least two things to consider if we switch to real boolean values:
I think we can update this method https://github.com/Automattic/jetpack/blob/master/modules/likes.php#L237-L244 |
I agree, plus the
Psuedocode, but I was thinking of something like... or if it is just a sitewide-notification, we can update it when Jetpack is updated a la https://github.com/Automattic/jetpack/blob/master/class.jetpack.php#L433 I haven't reviewed the existing code well enough to have an opinion if |
|
As a note, though, if this ends up being a rabbit hole, I am okay with accepting this PR after testing as is to restore expected functionality and opening a new issue to track the option migration in a future release. |
zinigor
left a comment
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.
I agree with @kraftbj and @jeherve here about it being weird to use on and off for boolean values. I couldn't find any more examples of this anywhere in Jetpack except the other setting for "Email me when someone follows my site". That's a good catch, @htdat ! Let's merge this one and weed out all the cases afterwards, so that we can migrate to real booleans seamlessly.
* Changelog: 8.1 additions * Changelog: add #13858 * Changelog: add #13963 * Changelog: add #14174 * Changelog: add #14178 * Changelog: add #14175 * Changelog: add #14192 * Changelog: add #14196 * Changelog: add #14182 * Changelog: add #14218 * Changelog: add #14214 * Changelog: add #13757 * Changelog: add #14190 * Changelog: add #14131 * Changelog: add #14101 * Changelog: add #14203 * Changelog: add #14211 * Changelog: add #14224 * Changelog: add #14230 * Changelog: add #14241 * Changelog: add #14249 * Changelog: add #14264 * Changelog: add #14263 * Changelog: add #14256 * Changelog: add #10189 * Changelog: add #14240 * Changelog: add #14239 Also added some new entries to the testing file. Co-authored-by: Igor Zinovyev <[email protected]>
* Changelog: 8.1 additions * Changelog: add #13858 * Changelog: add #13963 * Changelog: add #14174 * Changelog: add #14178 * Changelog: add #14175 * Changelog: add #14192 * Changelog: add #14196 * Changelog: add #14182 * Changelog: add #14218 * Changelog: add #14214 * Changelog: add #13757 * Changelog: add #14190 * Changelog: add #14131 * Changelog: add #14101 * Changelog: add #14203 * Changelog: add #14211 * Changelog: add #14224 * Changelog: add #14230 * Changelog: add #14241 * Changelog: add #14249 * Changelog: add #14264 * Changelog: add #14263 * Changelog: add #14256 * Changelog: add #10189 * Changelog: add #14240 * Changelog: add #14239 Also added some new entries to the testing file. Co-authored-by: Igor Zinovyev <[email protected]>
When working and testing #14239, I notice that it's not possible to really switch off
Someone likes one of my postsfrom /wp-admin/options-discussion.php. This PR is to fix this issue.Steps to replicate this issue
Someone likes one of my postsoption.Someone likes one of my postsis always enabled when it should NOT.Debugging and changes proposed in this Pull Request:
With \Jetpack_Likes::admin_discussion_likes_settings_validate(),
social_notifications_likecan be onlyonoroffif trying to update this option in /wp-admin/options-discussion.php\Jetpack_Core_Json_Api_Endpoints::cast_value() is responsible to check and return boolean types. However, it does not check two strings
onandoffvalues at all.That's why even with
off, it will be returntruewith this assessment:This PR will help check
onandoffstrings to return expected values (false / true) for REST API.Proposed changelog entry for your changes: