#20645 closed defect (bug) (fixed)
'delete_term' action doesn't pass the deleted term object
Reported by: | bigdawggi | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
The 'delete_term' action passes 3 params ($term, $tt_id, $taxonomy), just like the 'create_term' action. The issue is that the $term passed to 'delete_term' is not a term object, but instead the term ID; and the issue with that, is there's no longer a way to have anything that hooks on this 'delete_term' action reference information about the term while it was still around.
My use case:
I hooked on 'create_term' to perform actions based on the properties of the $term object. On 'delete_term' I needed to access those properties to perform respective actions counting on $term to be an object (as mentioned in the DocBlock)
* @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action * hooks, passing term object, term id. 'delete_term' gets an additional * parameter with the $taxonomy parameter.
The $term passed to 'delete_term' action was not an object, but instead the ID for the term (which doesn't help b/c the term's deleted and I can't look it up anymore at the point of the action).
The attached patch stores the deleted $term object prior to the actual deletion of the term, and passes it through to the following actions so they can utilize the old properties of the term. (e.g., slug, name, etc.).
Attachments (2)
Change History (10)
#2
follow-up:
↓ 3
@
12 years ago
In order to keep backwards compatibility, $deleted_term
should be added as a new parameter rather than replace an existing one.
#3
in reply to:
↑ 2
@
12 years ago
Replying to SergeyBiryukov:
In order to keep backwards compatibility,
$deleted_term
should be added as a new parameter rather than replace an existing one.
Added new patch for that. Thanks!
#4
@
12 years ago
- Component changed from General to Taxonomy
- Keywords has-patch 3.5-early added
- Milestone changed from Awaiting Review to Future Release
#5
follow-up:
↓ 6
@
12 years ago
Can this be reviewed to put into the next minor release instead of 3.5?
#6
in reply to:
↑ 5
@
12 years ago
- Keywords 3.5-early removed
- Milestone changed from Future Release to 3.5
Replying to bigdawggi:
Can this be reviewed to put into the next minor release instead of 3.5?
No, minor releases are for security and regression fixes only.
Correction, the 'created_term' action passes the term ID as the first parameter -- not the object.
I still think that we should pass the term object to the 'delete_term' action, since the actions hooking on that cannot look up the term any more and we may as well pass the object that has more information about the term around.
Open to suggestions...