Fix 'timeinfo' cache invalidation. Fixes #14922

git-svn-id: http://svn.automattic.com/wordpress/trunk@16537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-11-22 21:45:45 +00:00
parent 0324721ed2
commit 2ec0d0509e
2 changed files with 9 additions and 11 deletions

View File

@ -4171,23 +4171,20 @@ function _get_last_post_time( $timezone, $field ) {
if ( !in_array( $field, array( 'date', 'modified' ) ) )
return false;
$post_types = get_query_var('post_type');
if ( empty($post_types) )
$post_types = 'post';
$timezone = strtolower( $timezone );
$post_types = apply_filters( "get_lastpost{$field}_post_types", (array) $post_types );
$key = "lastpost{$field}:" . get_current_blog_id() . ":$timezone:" . md5( serialize( $post_types ) );
$key = "lastpost{$field}:$timezone";
$date = wp_cache_get( $key, 'timeinfo' );
if ( !$date ) {
$add_seconds_server = date('Z');
$post_types = get_post_types( array( 'publicly_queryable' => true ) );
array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
$post_types = "'" . implode( "', '", $post_types ) . "'";
switch ( strtolower( $timezone ) ) {
switch ( $timezone ) {
case 'gmt':
$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
break;
@ -4450,9 +4447,10 @@ function _transition_post_status($new_status, $old_status, $post) {
// If published posts changed clear the lastpostmodified cache
if ( 'publish' == $new_status || 'publish' == $old_status) {
wp_cache_delete( 'lastpostmodified:server', 'timeinfo' );
wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' );
wp_cache_delete( 'lastpostmodified:blog', 'timeinfo' );
foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
}
}
// Always clears the hook in case the post status bounced from future to draft.

View File

@ -35,7 +35,7 @@ if ( function_exists( 'date_default_timezone_set' ) )
wp_unregister_GLOBALS();
// Ensure these global variables do not exist so they do not interfere with WordPress.
unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
unset( $wp_filter, $cache_lastcommentmodified );
// Standardize $_SERVER variables across setups.
wp_fix_server_vars();