[wp-trac] [WordPress Trac] #19949: Make update_post_thumbnail_cache() work for any instance

WordPress Trac noreply at wordpress.org
Tue Nov 27 00:29:51 UTC 2012


#19949: Make update_post_thumbnail_cache() work for any instance
---------------------------------+-----------------------------
 Reporter:  scribu               |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Performance          |     Version:
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 3.5-early  |
---------------------------------+-----------------------------

Comment (by Ploobers):

 It's become very frustrating for me to try and maintain two separate query
 styles, as I prefer to use the built-in get_posts, but as I'm using
 thumbnails all over my site in custom loops, not having the images cached
 is causing 50-150 extra queries per page. In the meantime, I've just been
 using my own direct query.

 {{{
 SELECT p.ID, p.post_title, p.post_name, p.post_parent, p.post_type, a.ID
 AS image_id,
                 MAX( IF ( apm.meta_key='_wp_attachment_metadata',
 apm.meta_value,' ') ) as 'image_data',
                 MAX( IF ( apm.meta_key='_wp_attached_file',
 apm.meta_value,' ') ) as 'filepath'
                 FROM sr_posts p
                 INNER JOIN sr_postmeta pm ON p.ID = pm.post_id
                 INNER JOIN sr_posts a ON pm.meta_value = a.ID
                 INNER JOIN sr_postmeta apm ON a.ID = apm.post_id
                 WHERE p.post_parent = '$connect_id'
                 AND pm.meta_key = '_thumbnail_id'
                 AND ( apm.meta_key = '_wp_attachment_metadata'
                 OR apm.meta_key = '_wp_attached_file')
                 $where GROUP BY p.ID
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19949#comment:14>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list