From cac2e59fda0e572400ca220970132b55892708a2 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 16 Nov 2009 22:42:58 +0000 Subject: [PATCH] Force destruction of SimplePie objects for versions of PHP that don't release memory properly. Props arena, scribu. fixes #11074 git-svn-id: https://develop.svn.wordpress.org/trunk@12193 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/dashboard.php | 18 +++++++++++++++++- wp-includes/default-widgets.php | 11 ++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 4c0a2637f8..89609adbfc 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -624,11 +624,15 @@ function wp_dashboard_incoming_links_output() { printf(__('RSS Error: %s'), $rss->get_error_message()); echo '

'; } + $rss->__destruct(); + unset($rss); return; } if ( !$rss->get_item_quantity() ) { echo '

' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "

\n"; + $rss->__destruct(); + unset($rss); return; } @@ -682,7 +686,8 @@ function wp_dashboard_incoming_links_output() { } echo "\n"; - + $rss->__destruct(); + unset($rss); } function wp_dashboard_incoming_links_control() { @@ -737,12 +742,18 @@ function wp_dashboard_secondary_output() { printf(__('RSS Error: %s'), $rss->get_error_message()); echo '

'; } + $rss->__destruct(); + unset($rss); } elseif ( !$rss->get_item_quantity() ) { + $rss->__destruct(); + unset($rss); return false; } else { echo '
'; wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); echo '
'; + $rss->__destruct(); + unset($rss); } } @@ -825,6 +836,9 @@ function wp_dashboard_plugins_output() { echo "

$label

\n"; echo "
$title
 (" . __( 'Install' ) . ")\n"; echo "

$description

\n"; + + $$feed->__destruct(); + unset($$feed); } } @@ -922,6 +936,8 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); else $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); + $rss->__destruct(); + unset($rss); } update_option( 'dashboard_widget_options', $widget_options ); } diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 27c3b3cfa8..a0cc15a23f 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -732,6 +732,8 @@ class WP_Widget_RSS extends WP_Widget { echo $before_title . $title . $after_title; wp_widget_rss_output( $rss, $instance ); echo $after_widget; + $rss->__destruct(); + unset($rss); } function update($new_instance, $old_instance) { @@ -770,7 +772,8 @@ function wp_widget_rss_output( $rss, $args = array() ) { if ( is_wp_error($rss) ) { if ( is_admin() || current_user_can('manage_options') ) echo '

' . sprintf( __('RSS Error: %s'), $rss->get_error_message() ) . '

'; - + $rss->__destruct(); + unset($rss); return; } @@ -787,6 +790,8 @@ function wp_widget_rss_output( $rss, $args = array() ) { if ( !$rss->get_item_quantity() ) { echo ''; + $rss->__destruct(); + unset($rss); return; } @@ -838,6 +843,8 @@ function wp_widget_rss_output( $rss, $args = array() ) { } } echo ''; + $rss->__destruct(); + unset($rss); } @@ -947,6 +954,8 @@ function wp_widget_rss_process( $widget_rss, $check_feed = true ) { while ( stristr($link, 'http') != $link ) $link = substr($link, 1); } + $rss->__destruct(); + unset($rss); } return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );