Opened 14 years ago
Closed 14 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: |
Description
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.
Attachments (1)
Change History (8)
#1
@
14 years ago
- Keywords has-patch added
- Milestone changed from Unassigned to 3.1
- Type changed from defect (bug) to enhancement
#2
@
14 years ago
- Summary changed from Notification mechanism for deprecated filters/actions to Notification mechanism for deprecated actions
#3
@
14 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
#5
@
14 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?
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.