[wp-trac] [WordPress Trac] #37684: Allow sites to have filterable "states" akin to posts & media
WordPress Trac
noreply at wordpress.org
Tue Oct 8 17:33:07 UTC 2019
#37684: Allow sites to have filterable "states" akin to posts & media
--------------------------------------+------------------------------
Reporter: johnjamesjacoby | Owner: johnjamesjacoby
Type: enhancement | Status: reopened
Priority: normal | Milestone: 5.3
Component: Networks and Sites | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch needs-dev-note | Focuses: multisite
--------------------------------------+------------------------------
Changes (by johnjamesjacoby):
* keywords: 2nd-opinion has-patch needs-dev-note => has-patch needs-dev-
note
* status: closed => reopened
* resolution: fixed =>
Comment:
Replying to [comment:33 pbiron]:
> As far as I can tell, `$_site` is **always** a direct row from the blogs
table and hence, the values in the various status properties will
**always** be strings (either `"0"` or `"1"`). Can anyone confirm that?
The `WP_Site` class includes this in the various property documentations:
{{{
* A numeric string, for compatibility reasons.
}}}
> Or was the comparison (introduced in
[https://core.trac.wordpress.org/attachment/ticket/37684/37684.03.diff
37684.03.diff] and carried through all the subsequent patches) made loose
intentionally because under some circumstances those properties might be
ints?
I can't speak with authority on this, because while I prefer strict
comparisons in my own code, there are reasons not to be strict in
WordPress, and I consider this one of those cases.
> For WPCS purposes, would it make sense to do:
>
> * `if ( 1 === intval( $_sites->{$status} ) )`
This seems fine. Another idea is to use `absint()` on that status. It is
derived from a `tinyint` database column type, and `absint()` would
prevent cleverly disguising this with negative values via hooks.
I am comfortable committing your recommendation (not `absint()` for now)
and we can revisit further hardening anytime afterwards.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37684#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list