#33485 closed defect (bug) (fixed)
$deleted_term in wp_delete_term() has incorrect `count` value
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
It's assigned after all of the term relationships are removed. When accessing it through the delete_term
action, I'd expect it to persist the original count
.
Attachments (1)
Change History (12)
#2
follow-up:
↓ 3
@
10 years ago
@boonebgorges, Do you mean to pass a count
parameter to the delete_term_taxonomy
action? I checked the source code and I saw that delete_term_taxonomy
only receives the term_id.
#3
in reply to:
↑ 2
;
follow-up:
↓ 4
@
10 years ago
Replying to nicholas_io:
@boonebgorges, Do you mean to pass a
count
parameter to thedelete_term_taxonomy
action? I checked the source code and I saw thatdelete_term_taxonomy
only receives the term_id.
No, I mean that the $deleted_term
variable should be initialized before its term relationships are deleted. That way, $deleted_term->count
will reflect the pre-delete state of the term. I assume that you can just switch the blocks of code around, but this needs testing (and possibly a unit test).
#4
in reply to:
↑ 3
@
10 years ago
Replying to boonebgorges:
Replying to nicholas_io:
@boonebgorges, Do you mean to pass a
count
parameter to thedelete_term_taxonomy
action? I checked the source code and I saw thatdelete_term_taxonomy
only receives the term_id.
No, I mean that the
$deleted_term
variable should be initialized before its term relationships are deleted. That way,$deleted_term->count
will reflect the pre-delete state of the term. I assume that you can just switch the blocks of code around, but this needs testing (and possibly a unit test).
Ok, I got it, I'll try to make patch.
#7
follow-up:
↓ 9
@
10 years ago
- Milestone changed from Future Release to 4.4
Thanks, nicholas_io! Patch looks good. I'm going to reconfigure the unit test a little bit to (a) make it compatible with PHP 5.2, and (b) keep the assertions in the scope of the main test method rather than the 'wp_delete_term' callback (which is how we do it elsewhere in the test suite).
#9
in reply to:
↑ 7
;
follow-up:
↓ 10
@
10 years ago
Replying to boonebgorges:
Thanks, nicholas_io! Patch looks good. I'm going to reconfigure the unit test a little bit to (a) make it compatible with PHP 5.2, and (b) keep the assertions in the scope of the main test method rather than the 'wp_delete_term' callback (which is how we do it elsewhere in the test suite).
Great, I was in doubt about how do test inside callbacks, now I understood how is done.
#10
in reply to:
↑ 9
;
follow-up:
↓ 11
@
10 years ago
Replying to nicholas_io:
Replying to boonebgorges:
Thanks, nicholas_io! Patch looks good. I'm going to reconfigure the unit test a little bit to (a) make it compatible with PHP 5.2, and (b) keep the assertions in the scope of the main test method rather than the 'wp_delete_term' callback (which is how we do it elsewhere in the test suite).
Great, I was in doubt about how do test inside callbacks, now I understood how is done.
Your technique was good too, I'm just trying to be consistent :) Thanks again for the patch!
#11
in reply to:
↑ 10
@
10 years ago
Replying to boonebgorges:
Replying to nicholas_io:
Replying to boonebgorges:
Thanks, nicholas_io! Patch looks good. I'm going to reconfigure the unit test a little bit to (a) make it compatible with PHP 5.2, and (b) keep the assertions in the scope of the main test method rather than the 'wp_delete_term' callback (which is how we do it elsewhere in the test suite).
Great, I was in doubt about how do test inside callbacks, now I understood how is done.
Your technique was good too, I'm just trying to be consistent :) Thanks again for the patch!
All good! No problem :)
Yeah, it hardly seems worth passing
count
if it's always 0. At the very least, I'd expect'delete_term_taxonomy'
to get the pre-delete count.