#16182 closed defect (bug) (duplicate)
object_term_cache is never cleared for custom post types with non-shared taxonomy
| Reported by: | prettyboymp | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 3.0 |
| Severity: | major | Keywords: | |
| Cc: | Focuses: |
Description
wp_insert_post() calls clean_post_cache() after updating the post. However, when clean_object_term_cache() is called, it passes is hard coded to pass in the post_type of 'post'. So the object_term_cache is never cleared for any taxonomies that are part of the post object type's taxonomies.
Change History (13)
#6
@
16 years ago
Adding steps to reproduce:
- Create a custom post type
- Create a custom taxonomy and register it to the custom post type, but not the normal post
- Setup persistent object caching
- Setup and call code that uses get_the_terms() on an instance of the custom post type for the custom taxonomy
- Update the selected terms for the custom post through the admin
- Call get_the_terms() a second time, the terms will be pulled from cache with the previous value.
#7
@
16 years ago
The simple fix would be to update the wp_cache_delete() call within the clean_post_cache() function to be based off of the post_id's post type. Though this section should probably be re-factored to merge clean_post_cache() and clean_page_cache() into one function and calling the unique functionality through a 'clean_{$post_type}_cache' hook.
Due to the 3.1 time line, I think the simple fix should be implemented now and we should come back to the bigger re-factoring later.
#8
@
16 years ago
- Keywords needs-patch added
This bug is lame. Can you workaround with the clean_post_cache hook?
#9
@
16 years ago
Just because there is a work around doesn't mean it isn't a bug. It has the potential to cause a lot of issue when cache is holding on to a different value than the DB is and for the taxonomies that are linked to 'posts' or 'pages' to act completely differently from any other taxonomy is a debugging nightmare.
#11
@
13 years ago
- Keywords close added; needs-patch removed
- Resolution → invalid
- Status new → closed
This was fixed in r20569 which passes the $post object to all cache cleaning functions.
#12
@
13 years ago
- Keywords close removed
- Milestone Awaiting Review
- Resolution invalid → duplicate
Duplicate of #20486.
#13
@
13 years ago
Sorry, prettyboymp, I just saw your three year old reply :)
By "this bug is lame" I meant "This bug in annoying". I did not mean that the bug report was bad or that we shouldn't fix it. I suggested the workaround in case you were being hit by this bug and couldn't wait until it eventually got fixed in core.
Apologies for being unclear.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Sorry for the complete typo on this:
wp_insert_post() calls clean_post_cache() after updating the post. However, when clean_object_term_cache() is called, it is hard coded to pass in the post_type of 'post'. So the object_term_cache is never cleared for any taxonomies that are part of the post object type's taxonomies.