Update the self-referential destruction sequence in WP_Widget_RSS to account for trailing slashes. TODO: Strengthen our validation here.

git-svn-id: http://svn.automattic.com/wordpress/trunk@17765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-04-29 14:44:43 +00:00
parent 90928c0251
commit 52e6f54063
2 changed files with 27 additions and 5 deletions

View File

@ -925,9 +925,17 @@ function wp_dashboard_plugins() {
* @since 2.5.0
*/
function wp_dashboard_plugins_output() {
$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
$new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
$updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
ob_start();
$check_urls = array(
'http://wordpress.org/extend/plugins/rss/browse/popular/',
'http://wordpress.org/extend/plugins/rss/browse/new/',
'http://wordpress.org/extend/plugins/rss/browse/updated/'
);
$transient_key = __FUNCTION__ . serialize( '' ) . implode( '|', $check_urls );
$popular = fetch_feed( $check_urls[0] );
$new = fetch_feed( $check_urls[1] );
$updated = fetch_feed( $check_urls[2] );
if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
$plugin_slugs = array_keys( get_plugins() );
@ -998,6 +1006,7 @@ function wp_dashboard_plugins_output() {
$$feed->__destruct();
unset($$feed);
}
set_transient( $transient_key, ob_get_flush() );
}
/**
@ -1018,10 +1027,13 @@ function wp_dashboard_plugins_output() {
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading">' . __( 'Loading&#8230;' ) . '</p>';
$widgets = get_option( 'dashboard_widget_options' );
$output_cache = 'dashboard_' . md5( $callback . serialize( isset( $widgets[$widget_id] ) ? $widgets[$widget_id] : '' ) . implode( '|', $check_urls ) );
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) ) {
echo $loading;
delete_transient( $output_cache );
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
@ -1032,10 +1044,19 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
$cache = new WP_Feed_Cache_Transient('', md5($check_url), '');
if ( ! $cache->load() ) {
echo $loading;
delete_transient( $output_cache );
return false;
}
}
if ( false === $cache = get_transient( $output_cache ) ) {
echo $loading;
return false;
}
echo $cache;
return true;
/*
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 2 );
array_unshift( $args, $widget_id );
@ -1043,6 +1064,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
}
return true;
*/
}
/* Dashboard Widgets Controls */

View File

@ -713,7 +713,7 @@ class WP_Widget_RSS extends WP_Widget {
return;
// self-url destruction sequence
if ( $url == site_url() || $url == home_url() )
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
return;
$rss = fetch_feed($url);