Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 23 months ago

#42698 closed defect (bug) (fixed)

Dynamic Hooks that use REQUEST / GET / POST variables

Reported by: ramiy's profile ramiy Owned by: drewapicture's profile DrewAPicture
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:

Attachments (2)

42698.patch (4.4 KB) - added by ramiy 7 years ago.
42698.2.patch (4.5 KB) - added by ramiy 7 years ago.

Download all attachments as: .zip

Change History (8)

@ramiy
7 years ago

#1 @ramiy
7 years ago

  • Keywords has-patch added

@DrewAPicture please review the ticket and the attached patch.

#2 @DrewAPicture
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.

@ramiy
7 years ago

#3 @ramiy
7 years ago

@DrewAPicture Currently we don't check if super-globals are set, but I added isset() checks to the patch.

#4 @DrewAPicture
7 years ago

  • Milestone changed from Awaiting Review to 5.0

#5 @DrewAPicture
7 years ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 42349:

Hooks: Standardize naming of dynamic hooks using values derived from superglobals to use interpolation vs concatenation.

This is a continuation of the work that happened in [38307] for #37748.

Props ramiy.
Fixes #42698.

#6 @johnbillion
6 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.