[wp-trac] [WordPress Trac] #9500: Object caching is incompatible with mutative the_posts filters.

WordPress Trac wp-trac at lists.automattic.com
Thu Apr 9 20:05:47 GMT 2009


#9500: Object caching is incompatible with mutative the_posts filters.
--------------------------+-------------------------------------------------
 Reporter:  Antiarc       |       Owner:  anonymous 
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:  2.7.1     
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 query.php runs something like:

 1. Get the posts
 2. Run the_posts filters
 3. Save $posts in object cache

 The problem is that when you go to edit a post, get_post() checks the
 object cache for a post before pulling it from the DB. Thus, presume the
 following:

 1. We pull a post, with the content "foo".
 2. We run a the_posts hook, maybe with a regex that transforms "foo" into
 "foobar".
 3. $posts are saved in the object cache
 4. We go to edit a post. Post is pulled from the object cache, as "foobar"
 - not what the user entered into their post.
 5. We save the post without any editing. Post gets saved as "foobar".
 6. The post is pulled from the DB and the_posts is run. Our regex
 transforms it to "foobarbar", etc etc.

 I know that transformative actions are generally done on the_content, but
 in this particular case, I absolutely have to be doing batched operations
 on all posts pulled (it's sending content off to a remote server for
 processing, and running that on the_content would generate N requests per
 page, rather than 1 request per page, incurring massive slowdown). The
 docs do not forbid transformation by the_posts, and I can't find a more
 appropriate hook to use, nor is there a hook to invalidate the contents of
 the object cache before editing happens.

 This used to be correct, but was changed in r4517 - the commit message
 there is kind of bogus. I've attached a patch with the fix.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9500>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list