Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16051 closed defect (bug) (duplicate)

$taxonomy_children option is not updated after wp_insert_term

Reported by: acsnaterse's profile acsnaterse Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Taxonomy Keywords: has-patch reporter-feedback
Focuses: Cc:


When using wp_insert_term or wp_update_term the $taxonomy_children option is not set properly. This should be done in the _get_term_hierarchy function, but I think the following line gives a problem:

if ( is_array($children) )
	return $children;

It checks whether it's an array or not, but this means when the array is empty (due to manually deleting all the terms in the Admin) it also returns. And therefor it doesn't update anymore.

I think the check must be whether it's an array or not and if it is, it should also check whether the array is empty or not. So something like this:

if ( is_array($children) && !empty($children) )
	return $children;

Attachments (1)

taxonomy-childs.patch (660 bytes) - added by acsnaterse 13 years ago.
Added statement for checking whether {$taxonomy}_children option is empty

Download all attachments as: .zip

Change History (3)

13 years ago

Added statement for checking whether {$taxonomy}_children option is empty

#1 @mdawaffe
13 years ago

  • Keywords reporter-feedback added

Related? #14399, #14485

The patch looks wrong to me, since the option should be an empty array for a hierarchical taxonomy with now child terms.

Can you provide some test code that reproduces this problem?

#2 @dd32
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #14485 (and #16051, #14704, #17356)

Note: See TracTickets for help on using tickets.