[wp-trac] [WordPress Trac] #30875: enforce integers in add_filter priority
WordPress Trac
noreply at wordpress.org
Thu Jan 4 19:28:02 UTC 2024
#30875: enforce integers in add_filter priority
-----------------------------+-------------------------
Reporter: drrobotnik | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Plugins | Version: 4.1
Severity: normal | Resolution: maybelater
Keywords: has-patch close | Focuses:
-----------------------------+-------------------------
Changes (by hellofromTonya):
* keywords: has-patch dev-feedback close => has-patch close
* status: assigned => closed
* resolution: => maybelater
Comment:
Following up on older close candidate tickets.
The priority is clearly documented as requiring an integer data type.
Passing it anything other than an int is doing it wrong. That said,
requiring only an `int` could and likely will cause unexpected
behaviors/results for users. There's an argument for back-compat concerns
due to how essential (dare say mission critical) hooks are in WordPress.
I'm not convinced there's enough benefit to integer enforcement (input
validation) to overcome the risks to users and extenders.
If data type strictness is truly needed for the priority (for example, to
ensure its compatible with a future PHP version that will impact it), then
an intentional slow campaign is warranted. For example, first inform
through deprecation or notice with a long runway before raising the error
level to enforce the integer data type and take action (such as bailing
out or setting a default priority value).
What about tests that validate the current priority call order? There are
limited tests now. More would be appreciated and helpful. But I think that
can be handled in a separate ticket to avoid confusion of what actions
were taken in this ticket.
Actions:
* Opening a new ticket for more tests to be added for testing happy and
unhappy paths for actions/filters priority call orders.
* Closing this ticket as `maybelater` conditioned on the premise that
later = if needed for compatibility with a future PHP version that has a
severe enough impact on this area of the code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30875#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list