[wp-trac] [WordPress Trac] #15805: get_page_by_title() lacks caching

WordPress Trac noreply at wordpress.org
Fri Aug 23 13:24:01 UTC 2013


#15805: get_page_by_title() lacks caching
-------------------------------------+------------------
 Reporter:  Viper007Bond             |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  3.7
Component:  Performance              |     Version:  3.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+------------------

Comment (by tollmanz):

 I think there are a few potential issues with the suggested patch.

 1. {{{$post_type}}} should be considered in the cache key. If not, looking
 up the page with title "This is my title" will return the same result as a
 post with title "This is my title" if it is pulled from cache.
 1. How is the cache invalidated? Theoretically, the value is being cached
 indefinitely (although different caching engine will likely naturally
 purge the cache over time), which can cause some bizarre behaviors. For
 instance, if a post with title "This is my title" is created, subsequently
 deleted, then a new post with title ""This is my title" is created, the
 cached value would be the ID of the original post. I think we would need
 something along the lines of the following code to run on post trash and
 delete:

 {{{
 $key = 'post_title_' . get_the_title( $post_id ) . get_post_type( $post_id
 );
 wp_cache_delete( $key, 'posts' );
 }}}

 3. I think the patch needs further refreshing as {{{get_page}}} is used in
 the function, whereas current code uses {{{get_post}}}.

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


More information about the wp-trac mailing list