From 84f5771dfaad201243de8303f89839e1d380fe7a Mon Sep 17 00:00:00 2001 From: azaozz Date: Sun, 26 Apr 2009 05:34:06 +0000 Subject: [PATCH] Fix conversion of old widget settings for Recent Posts, see #8441 git-svn-id: http://svn.automattic.com/wordpress/trunk@11088 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-widgets.php | 16 ++++++++++------ wp-includes/widgets.php | 7 +++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 407af8f586..e3444e777b 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -495,7 +495,8 @@ class WP_Widget_Recent_Posts extends WP_Widget { function WP_Widget_Recent_Posts() { $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your blog") ); - $this->WP_Widget('recent_posts', __('Recent Posts'), $widget_ops); + $this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops); + $this->alt_option_name = 'widget_recent_entries'; add_action( 'save_post', array(&$this, 'flush_widget_cache') ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); @@ -503,11 +504,10 @@ class WP_Widget_Recent_Posts extends WP_Widget { } function widget($args, $instance) { - if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) + if ( $output = wp_cache_get('widget_recent_posts' . $args['widget_id'], 'widget') ) return print($output); ob_start(); - extract($args); $title = empty($instance['title']) ? __('Recent Posts') : apply_filters('widget_title', $instance['title']); @@ -517,7 +517,7 @@ class WP_Widget_Recent_Posts extends WP_Widget { $number = 1; else if ( $number > 15 ) $number = 15; - + $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); if ($r->have_posts()) : ?> @@ -532,8 +532,8 @@ class WP_Widget_Recent_Posts extends WP_Widget { flush_widget_cache(); + + $alloptions = wp_cache_get( 'alloptions', 'options' ); + if ( isset($alloptions['widget_recent_entries']) ) + delete_option('widget_recent_entries'); return $instance; } diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index c728fdb060..80f69fab77 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -267,6 +267,9 @@ class WP_Widget { function get_settings() { $settings = get_option($this->option_name); + + if ( false === $settings && isset($this->alt_option_name) ) + $settings = get_option($this->alt_option_name); if ( !is_array($settings) ) $settings = array(); @@ -976,9 +979,9 @@ function wp_convert_widget_settings($base_name, $option_name, $settings) { if ( empty($settings) ) { $single = true; } else { - if ( isset($settings['number']) ) - unset($settings['number']); foreach ( array_keys($settings) as $number ) { + if ( 'number' == $number ) + continue; if ( !is_numeric($number) ) { $single = true; break;