#38445 closed enhancement (maybelater)
Rest Sanitize Boolean
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | close |
Focuses: | Cc: |
Description
Since version 4.7.0 a new function named <strong>rest_sanitize_boolean</strong> is added to the rest-api core.
This function seems to be a general function ( that per documentation Changes a boolean-like value into the proper boolean value. ) rather than a specific function that works only within the restapi context.
We had a discussion about this in #core-restapi and they tell me that the purpose of the function is when a request is made via GET like ?hide_empty=false or ?hide_empty=0 for example.
The value is evaluated as a string, so this when the function come into play.
Can this function be useful even in general context when a form validation is performed via $_GET or $_POST.
So, may I propose to move the function within the <strong>formatting.php</strong> so that we can benefit in various situations?
Change History (3)
#2
@
7 years ago
- Keywords close added
- Milestone Future Release deleted
- Resolution set to maybelater
- Status changed from new to closed
I agree with @joehoyle here. I don't see a reason to move the function to formatting.php until it is used outside of the REST API logic.
#3
@
7 years ago
We have wp_validate_boolean() since 4.0.0. I've not compared those two in detail, but I wonder if rest_sanitize_boolean()
was needed?
I don't think there's much point in moving this before it's been required elsewhere, so the patch to move this should probably just get committed with whatever that thing ends up being, if it ever ends up being anything.