#42698 closed defect (bug) (fixed)
Dynamic Hooks that use REQUEST / GET / POST variables
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | docs, performance | Cc: |
Description
The background for this ticket is naming-convention for dynamic hooks set in ticket #37748 and in the Coding Standards Best Practices.
WordPress core has 5 hooks that don't implement those best practices, hooks that use $_REQUEST, $_GET and $_POST variables as parameters in their names.
The attached patch fixes those hooks, replacing:
do_action( 'network_admin_edit_' . $_GET['action'] );
with:
do_action( "network_admin_edit_{$action}" );
Note that the change has other benefits like affecting the code reference slugs:
- https://developer.wordpress.org/reference/hooks/wp_ajax__requestaction/
- https://developer.wordpress.org/reference/hooks/admin_action__requestaction/
- https://developer.wordpress.org/reference/hooks/network_admin_edit__getaction/
- https://developer.wordpress.org/reference/hooks/wp_ajax_nopriv__requestaction/
- https://developer.wordpress.org/reference/hooks/network_sites_updated_message__getupdated/
Attachments (2)
Change History (8)
#2
@
7 years ago
@ramiy So, the patch is a good start, except that the new $action
initializations against superglobals need to check if they're set before assigning the value, defaulting to an empty string otherwise.
#3
@
7 years ago
@DrewAPicture Currently we don't check if super-globals are set, but I added isset()
checks to the patch.
@DrewAPicture please review the ticket and the attached patch.