[wp-trac] [WordPress Trac] #10381: post->ancestors isn't always set

WordPress Trac wp-trac at lists.automattic.com
Sun Jun 13 00:41:38 UTC 2010


#10381: post->ancestors isn't always set
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:  ryan                               
     Type:  defect (bug)       |      Status:  new                                
 Priority:  normal             |   Milestone:  3.1                                
Component:  Cache              |     Version:  2.8                                
 Severity:  normal             |    Keywords:  dev-feedback needs-unit-tests early
-------------------------------+--------------------------------------------
Changes (by shidouhikari):

 * cc: shidouhikari (added)


Comment:

 But is it a good idea to keep deleting cache and resetting it?

 I understand it's rarely needed, so every get_post() should delete post
 from cache and reset it?

 Also, Denis is only deleting cache when *any* external cache is being
 used. What if core cache is used, a previous post query didn't set
 ancestors, and another query in the same pageload is done and cached
 object is used? Or if in some other place a code tests if object is in
 cache and if so it doesn't even call get_post(), also not calling
 _get_post_ancestors()? Complicated :/


 It seems the best place to fix *ATM* this is indeed inside
 _get_post_ancestors(), because just after its 2 calls wp_cache_add() is
 called. So, wp_cache_add() will see there's no cache and set it. But what
 happens in, say, WP 3.5, _get_post_ancestors() is called somewhere else
 and everytime it happens cache is deleted? At that time nobody will know
 that wp_cache_delete() is being called inside it expecting for
 wp_cache_add() be used after it returns.

 I believe a long run for this is to update cache everytime ancestors is
 needed, therefore testing cache when _get_post_ancestors() is used and
 verifying if it has ancestors set. If post is cached and it has ancestors,
 nothing else must be done.


 Another note: regarding 10381.3.diff, since you are deleting post in cache
 everytime _get_post_ancestors() is called, regardless of if cache has
 ancestors or not. If cache has ancetors, there's no need to delete it.

 I know I'm not skilled enought to say any of these patches are wrong, but
 they are expecting that 2 codes (_get_post_ancestors and wp_cache_add) in
 different places are run together. This fixes the issue for now but
 there's really nothing forcing them to run together. If in the future they
 are used separated, it may create an even bigger problem (ex:
 _get_post_ancestors() is used in another file and starts deleting posts
 from cache without need).

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


More information about the wp-trac mailing list