[wp-trac] [WordPress Trac] #43312: PHP 7.2 warning in wp_kses_attr()
WordPress Trac
noreply at wordpress.org
Fri Mar 23 16:41:43 UTC 2018
#43312: PHP 7.2 warning in wp_kses_attr()
---------------------------------------------+-----------------------------
Reporter: andrei0x309 | Owner: SergeyBiryukov
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 4.9.5
Component: Formatting | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests commit | Focuses:
---------------------------------------------+-----------------------------
Comment (by soulseekah):
`count`ing a boolean will always return 1. Be it `true` or `false`,
doesn't matter. So the old logic is actually flawed. The `wp_kses_attr`
did indeed not short-circuit in the first condition and fell through doing
useless, extra work (`wp_kses_hair`, `preg_replace`). But if you look at
the resulting string and what it is composed of, then you'll see that it
is absolutely the same as in the case of short-circuiting.
`return "<$element$attr2$xhtml_slash>";` is equal to `return
"<$element$xhtml_slash>";`, `$attr2` is an empty string of attributes,
composed of `$attrarr` which is empty when `false` is passed.
Thus, the logic is absolutely identical, minus the extra work that nobody
really cares about. If anything, WordPress became faster :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43312#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list