From 2ec0d0509e5707be59902419a010d23b3f3ae1ab Mon Sep 17 00:00:00 2001 From: scribu Date: Mon, 22 Nov 2010 21:45:45 +0000 Subject: [PATCH] Fix 'timeinfo' cache invalidation. Fixes #14922 git-svn-id: http://svn.automattic.com/wordpress/trunk@16537 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 18 ++++++++---------- wp-settings.php | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index c76988fb63..1b82272212 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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. diff --git a/wp-settings.php b/wp-settings.php index 6a1f10e804..cb72c0d76a 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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();