[wp-trac] [WordPress Trac] #49628: Add is_post_type_viewable filter
WordPress Trac
noreply at wordpress.org
Sun Nov 7 01:24:18 UTC 2021
#49628: Add is_post_type_viewable filter
---------------------------------------------+-----------------------------
Reporter: powerbuoy | Owner: hellofromTonya
Type: feature request | Status: closed
Priority: normal | Milestone: 5.9
Component: Posts, Post Types | Version: 5.3.2
Severity: normal | Resolution: fixed
Keywords: has-patch needs-dev-note commit | Focuses: administration
---------------------------------------------+-----------------------------
Comment (by Cybr):
Thank you for the patch! I have a comment on it, however.
> There's a risk of a backwards-compatiblity break in directly returning
the filtered value.
I'm not sure where this backward-compatibility issue lies. Isn't this a
newly introduced filter that augments an already boolean value? I believe
the defensive programming can be removed:
1. The documentation clearly states it should be a boolean.
2. The return value can be cast to a boolean `(bool) $is_viewable`, which
should suffice.
This adds 3 extra opcodes, of which 1 jump -- roughly 17 times per request
on a clean install.
If we want to focus on performance, we need to be reticent with
introducing defensive code and expect developers to abide by the types. I
think this is especially true (pun intended) for newly introduced and
substantially better-documented functions/methods/filters/actions.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49628#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list