Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#4500 closed defect (bug) (fixed)

wp_update_term_count is not increasing taxonomy count correctly.

Reported by: cavemonkey50 Owned by:
Milestone: 2.3 Priority: normal
Severity: major Version: 2.3
Component: Administration Keywords: has-patch
Focuses: Cc:


It appears that wp_set_object_terms is not always increasing the taxonomy count. When using the following code, the count is not increased:

register_taxonomy('podcast_format', 'custom_field');
wp_insert_term('Main Feed', 'podcast_format'); Run only once to create term
wp_set_object_terms($custom_field_id, 'main-feed', 'podcast_format', false);

I am aware of wp_update_term_count, but shouldn't wp_set_object_terms increase the count for us?

Attachments (1)

terms_update.diff (1015 bytes) - added by cavemonkey50 13 years ago.

Download all attachments as: .zip

Change History (4)

#1 @cavemonkey50
13 years ago

  • Cc ron@… added
  • Keywords has-patch added
  • Milestone set to 2.3 (trunk)
  • Severity changed from normal to major

I've tracked down the problem. wp_update_term_count is checking if $taxonomy->update_count_callback is set to a custom update function. The problem is $taxonomy->update_count_callback is always set to a default value of null. My attached patch also checks to see if the $taxonomy->update_count_callback is not set to null.

In addition, even once you get past that step, the actual update function needed to be in a foreach loop. My attached patch corrects this issue also.

Finally, I would just like to clarify that this not only affects custom taxonomies, but the taxonomy link_category also. link_category is not using a custom update function, therefore falls into this defect.

#2 @cavemonkey50
13 years ago

  • Summary changed from wp_set_object_terms is not increasing taxonomy count correctly. to wp_update_term_count is not increasing taxonomy count correctly.

#3 @ryan
13 years ago

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

(In [5866]) wp_update_term_count fixes from cavemonkey50. fixes #4500

Note: See TracTickets for help on using tickets.