Opened 3 years ago
Closed 3 years ago
#14821 closed enhancement (duplicate)
Add multiple post type support to update_object_term_cache()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Performance | Version: | 3.0.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
update_object_term_cache() only accepts one post_type. If a loop contains more than one post type then the object term cache isn't populated and your queries can go through the roof.
See http://lists.automattic.com/pipermail/wp-hackers/2010-September/034776.html
Patch coming up.
Attachments (2)
Change History (7)
johnbillion
— 3 years ago
comment:1
johnbillion
— 3 years ago
- Keywords has-patch added
comment:2
nacin
— 3 years ago
We should probably adjust update_object_term_cache() to accept multiple post types instead, that way we still keep to a single wp_get_object_terms() call.
Support for it should probably be pretty easy. Simply call get_object_taxonomies() for each post type and merge the result, I think.
johnbillion
— 3 years ago
comment:4
johnbillion
— 3 years ago
That does indeed work.
Updated patch changes update_object_term_cache() so it accepts a single object type or an array of object types.
update_post_caches() is also modified so it passes an array of the post types from the $posts array if $post_type is set to 'all'.
Patch.
This patch changes update_post_caches() so it calls update_object_term_cache() for each post type in the $posts array if the $post_type parameter isn't set or it's set to 'any'.