Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#12913 closed enhancement (duplicate)

Notification mechanism for deprecated actions

Reported by: strider72 Owned by: nacin
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: Cc:


Attaching a patch that implements a system for notifying when code uses an action that has been deprecated. The action 'retreive_password' has been marked as deprecated.

Doesn't apply to filters yet.

Also see http://core.trac.wordpress.org/ticket/12438

Attachments (1)

12913_wp_deprecated_filter_check.diff (4.2 KB) - added by strider72 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @strider72
12 years ago

  • Keywords has-patch added
  • Milestone changed from Unassigned to 3.1
  • Type changed from defect (bug) to enhancement

#2 @strider72
12 years ago

  • Summary changed from Notification mechanism for deprecated filters/actions to Notification mechanism for deprecated actions

#3 @nacin
12 years ago

  • Component changed from General to Plugins
  • Milestone changed from 3.1 to Future Release
  • Owner set to nacin
  • Status changed from new to reviewing

I've been wanting to do this for a while.

I don't think it is a good idea to add this directly to do_action and apply_filters calls, as we need these to perform as fast as possible. Additionally, the patch as attached would break any action that has multiple args attached to it.

Instead, I would suggest we issue a call _deprecated_hook( name of hook, version, replacement, message ) just after the hook is executed, and use did_action() in _deprecated_hook() to see whether we should actually trigger a deprecated_hook_used action and issue the E_NOTICE (if WP_DEBUG).

Might not be a bad idea to use _deprecated_action() and _deprecated_filter(), have one wrap the other, and simply use slightly different messages, just to be clear in both the source code and in the E_NOTICE that is produced.

#4 @nacin
12 years ago

  • Keywords has-patch removed

#5 @strider72
12 years ago

Okay... here's a thought: Is there a definitive "last" hook in WordPress? Right after that fires we could fire off a function that looks at did_action and compares it to an array of deprecated hooks, and fires _deprecated_filter as needed.

I was first trying to figure how to hook it after the do_action is called, but of course the problem there is that do_action fires even if there are no hooks attached to it.

Would it slow down do_action/apply_filter too much if we simply added an in_array to compare $tag to an array of deprecated hooks?

#6 @strider72
12 years ago

Note: the patch is still useful for the _deprecated_action and _deprecated_filter functions.

Nacin -- also note that $type does indicate in the error message whether it's an action or filter. If there are other types of hooks it could be wrapped just as _deprecated_action does.

#7 @westi
11 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reviewing to closed

Cross referencing with #10441 and closing as a dupe.

Note: See TracTickets for help on using tickets.