#38462 closed task (blessed) (fixed)
Fix identical hooks with differing parameters
Reported by: | johnbillion | Owned by: | |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | docs | Cc: |
Description
Two recent instances where a hook that is triggered in multiple places in core has ended up having differing parameters:
It would be ideal to have unit test coverage which scans core's PHP files for all instances of do_action
and apply_filters
, filters hooks that occur multiple times, and then verifies that every instance of the hook accepts the same number of parameters.
Change History (16)
#2
@
8 years ago
To parse all php files is very expensive and should be avoided in unit tests. I've compiled a list (from the 4.6.1 parsed data) of hooks that are triggered in multiple places with differing parameters.
For now we should update these hooks with the right parameters. We could have the docs parser store these hooks when parsing and correct them after upgrading WP.
#3
@
8 years ago
Thanks for that @keesiemeijer! Some of the inconsistencies there are a complete mess.
#4
@
8 years ago
Yeah, maybe this should be changed into a task instead of a feature request. Should I create a separate ticket for that?
Meanwhile I've found some more oddities that should be cleaned up.
This one (in a deprecated function) is missing a parameter in the database because it's not documented.
https://developer.wordpress.org/reference/hooks/the_content_rss/
These have differing parameter names in the DocBlock
hook | function |
---|---|
the_comments | WP_Comment_Query::get_comments |
the_sites | WP_Site_Query::get_sites |
posts_join | WP_Query::get_posts |
the_networks | WP_Network_Query::get_networks |
These have missing parameters in the DocBlock
hook | function |
---|---|
get_avatar | get_avatar |
show_post_locked_dialog | _admin_notice_post_locked |
fallback_intermediate_image_sizes | wp_generate_attachment_metadata |
These have Concatenated dynamic hooks
#7
@
7 years ago
- Component changed from Plugins to General
- Focuses docs added
- Keywords needs-patch added; needs-unit-tests removed
- Milestone changed from Awaiting Review to Future Release
- Summary changed from Unit test to detect identical hooks with differing parameters to Fix identical hooks with differing parameters
- Type changed from feature request to task (blessed)
I think we can drop the idea of unit testing this for now, and concentrate on fixing the differing parameters.
The docs parser could probably do this easily, since it already scans for all of the hooks anyway. Maybe there is a way to integrate it into the tests process, but just to scan for the hooks?