[wp-trac] [WordPress Trac] #39053: Add function `wp_validate_integer`
WordPress Trac
noreply at wordpress.org
Wed Apr 12 01:08:59 UTC 2017
#39053: Add function `wp_validate_integer`
----------------------------------------------------+------------------
Reporter: peterwilsoncc | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.8
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs-refresh | Focuses:
----------------------------------------------------+------------------
Comment (by johnjamesjacoby):
> Breaking and notifying about the problem makes it something that can be
reasoned about and a resolution to be implemented.
This is exactly the reason for a function like this to exist, but
integrating it into WordPress core will be tricky.
**When would it actually get used?**
On user POSTed values or GET query parameters? Do we use it again very
late in `$wpdb` before database writes occur? If all we want to do is make
sure a numeric variable is within the boundaries of what's allowed inside
a `BIGINT(20) unsigned` database column, does it make sense to do that
high-up in user-land or deep in the kernel?
We wouldn't want to use it everywhere, because function calls are slower
than simple type-casts, and add to that the additional mathematical
comparison logic against known large integers, and there's not a ton of
value in repeatedly checking that every object's ID is a sane value.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39053#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list