Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7357 closed defect (bug) (invalid)

wp_update_term_count_now default behavior doesn't work

Reported by: filosofo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: wp_update_term_count_now term taxonomy
Focuses: Cc:


wp_update_term_count_now takes as its first argument an array of term ids, and the terms' taxonomy as its second. Then it updates the terms' counts based on the number of times a term in that taxonomy has a relationship with an object.

If there is a update_search_term_count callback defined for that taxonomy, then wp_update_term_count_now calls the callback to do the term counting. Categories and tags do have their own update_search_term_count callback defined, so normally there is no problem.

However, for any taxonomy that does not have the callback defined, wp_update_term_count_now by default updates the count on its own. And that's where the problem is, because it suddenly treats term_ids as though they were term_taxonomy_ids, which doesn't work.

My patch fixes the problem by retrieving a term's term_taxonomy_id and updating the term count properly.

Attachments (1)

wp_update_term_count_now.diff (995 bytes) - added by filosofo 10 years ago.

Download all attachments as: .zip

Change History (4)

#1 @filosofo
10 years ago

Actually, ignore my description above; it's wrong. That's not what's happening at all.

What's happening is that the inline documentation incorrectly says they are "term ids," and the array of term_taxonomy_ids is frequently $terms, so it's doubly got me confused.

I'll create a new patch with better variable names and documentation.

#2 @filosofo
10 years ago

  • Milestone 2.7 deleted
  • Resolution set to invalid
  • Status changed from new to closed

#3 @jacobsantos
10 years ago

Well, that is the purpose of inline documentation, to let you know about stuff that you can't see. It will be most helpful, also, if you know any more about the taxonomy API, then can you take a look at the other inline documentation? Some other parts are most likely incorrect.

Note: See TracTickets for help on using tickets.