Ticket #36905: 36905.patch
File 36905.patch, 1.2 KB (added by , 8 years ago) |
---|
-
src/wp-includes/post.php
4327 4327 function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { 4328 4328 global $wpdb; 4329 4329 4330 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 4331 if ( false === $last_changed ) { 4332 $last_changed = microtime(); 4333 wp_cache_set( 'last_changed', $last_changed, 'posts' ); 4334 } 4335 4336 $hash = md5( $page_title . serialize( $post_type ) ); 4337 $cache_key = "get_page_by_title:$hash:$last_changed"; 4338 $cached = wp_cache_get( $cache_key, 'posts' ); 4339 if ( false !== $cached ) { 4340 // Special case: '0' is a bad `$page_path`. 4341 if ( '0' === $cached || 0 === $cached ) { 4342 return; 4343 } else { 4344 return get_post( $cached, $output ); 4345 } 4346 } 4347 4330 4348 if ( is_array( $post_type ) ) { 4331 4349 $post_type = esc_sql( $post_type ); 4332 4350 $post_type_in_string = "'" . implode( "','", $post_type ) . "'"; … … 4347 4365 4348 4366 $page = $wpdb->get_var( $sql ); 4349 4367 4368 // We cache misses as well as hits. 4369 wp_cache_set( $cache_key, $page, 'posts' ); 4370 4350 4371 if ( $page ) { 4351 4372 return get_post( $page, $output ); 4352 4373 }