Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31822 closed defect (bug) (invalid)

Hierarchical custom taxonomy not showing children in admin panel

Reported by: pinkivy's profile pinkivy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1.1
Component: Taxonomy Keywords:
Focuses: administration Cc:

Description (last modified by SergeyBiryukov)

I created a hierarchical custom taxonomy. When I am in a post, attaching these taxonomies, everything is fine. But in the admin screen for the taxonomy, I only see the top-level terms. The count at the upper-right of the listing does have the correct number of all terms, but only the very top level taxonomies show in the table. I can search for a child taxonomy and find it, and its parent is marked correctly; it just doesn't appear in the default table.
I have a _temporary fix_. I know that it is a horrible idea to edit core files, and I am not recommending that anyone do this. I am merely mentioning it because it may be helpful in getting a more proper fix into a newer release. ('academic_program_type' is the name of the taxonomy.)
In /wp-admin/edit-tags.php, before the call to $wp_list_table->display();, I added:

if ( 'academic_program_type' == $taxonomy ) 
{
	delete_option("academic_program_type_children");
	wp_cache_flush();	
}

Please skip the lecture on updating the core files and address the issue that the cache needs to be flushed in order to get children taxonomy items to show in the admin screen.
By the way, I also needed to flush the cache in order to traverse the taxonomy hierarchy in a custom template I created. If you're looking for related issues.

Change History (6)

#1 @boonebgorges
10 years ago

  • Component changed from General to Taxonomy

Please skip the lecture on updating the core files and address the issue that the cache needs to be flushed in order to get children taxonomy items to show in the admin screen.

No lecture was forthcoming. How can you identify and fix bugs in core files if you don't edit the core files?

I'm not able to reproduce this on my local installations. Can I ask for some additional info?

  • You are flushing the object cache and also deleting the 'academic_program_type_children' option. I assume you've verified that both of these are necessary to prevent the incorrect behavior you've described? This suggests that the 'academic_program_type_children' option is populated with a flat list that contains only top-level items. Have you verified that this is the case? Theoretically, this option should only be generated from https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/taxonomy.php#L3823, but the 'get' => 'all' param in that function should ensure that the entire tree is fetched.
  • Have you reproduced this with all plugins/mu-plugins disabled? It's possible that something is interfering either with get_terms() or something like that, and polluting the cache somehow.

If you're able to produce the problem on a completely vanilla installation of WP (save, of course, for the code that you're using to register the custom taxonomy), please share explicit details on how to reproduce the issue. This includes your custom taxonomy code, as well as whatever steps you're performing (presumably, creating some terms, publishing posts?, visiting edit-tags.php, all in some specific order). Thanks.

#2 @SergeyBiryukov
10 years ago

  • Description modified (diff)
  • Focuses administration added

#3 @pinkivy
10 years ago

Thanks for the quick response.
I have tried it with the plugins deactivated, but I haven't tried with a vanilla theme yet. I will have to do that and get back to you.

#4 @pinkivy
10 years ago

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

I copied the site over to a different subdomain so that I could test it more thoroughly, and I have found inconsistent behavior between the 2 sites during testing. I now think that the problem is caused by the caching mechanism of one of the plugins. My apologies. It is not a Wordpress problem.

#5 @boonebgorges
10 years ago

No apologies necessary - thanks for reporting and for following up.

#6 @DrewAPicture
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.