[wp-trac] [WordPress Trac] #51184: get_the_date() checks $format only for empty variable and fails on false boolean - since WP 5.5
WordPress Trac
noreply at wordpress.org
Sat Aug 29 07:11:36 UTC 2020
#51184: get_the_date() checks $format only for empty variable and fails on false
boolean - since WP 5.5
------------------------------------------+-----------------------------
Reporter: wittich | Owner: SergeyBiryukov
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.5.1
Component: Date/Time | Version: 5.5
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+-----------------------------
Changes (by Rarst):
* status: closed => reopened
* resolution: invalid =>
Comment:
I don't think we should indicate or check for boolean there, because it's
not meant to accept that at all. It's just _one_ way _how_ it can fail.
Technically `empty()` check would be better _equivalent_ for old code, but
it's meh when input can be non-empty but also not string that we want
(it's WordPress! inputs are garbage).
I would flip the statements and check for valid case first `if( is_string(
$format ) && '' !== $format )` and anything else would fall back to
default format.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51184#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list