From 02fb838f97081d0784bf5c273ef549eb89496c7e Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 18 Dec 2005 15:49:43 +0000 Subject: [PATCH] Fix ping races. fixes #2088 git-svn-id: http://svn.automattic.com/wordpress/trunk@3322 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/execute-pings.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/wp-admin/execute-pings.php b/wp-admin/execute-pings.php index 10be97b16e..e68f76cb55 100644 --- a/wp-admin/execute-pings.php +++ b/wp-admin/execute-pings.php @@ -7,27 +7,21 @@ register_shutdown_function('execute_all_pings'); function execute_all_pings() { global $wpdb; // Do pingbacks - if($pings = $wpdb->get_results("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme';")) { - foreach($pings as $ping) { - pingback($ping->post_content, $ping->ID); - echo "Pingback: $ping->post_title : $ping->ID
"; - $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); - } + while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { + $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); + pingback($ping->post_content, $ping->ID); + echo "Pingback: $ping->post_title : $ping->ID
"; } // Do Enclosures - if($enclosures = $wpdb->get_results("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme';")) { - foreach($enclosures as $enclosure) { - do_enclose($enclosure->post_content, $enclosure->ID); - echo "Enclosure: $enclosure->post_title : $enclosure->ID
"; - $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); - } + while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { + $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); + do_enclose($enclosure->post_content, $enclosure->ID); + echo "Enclosure: $enclosure->post_title : $enclosure->ID
"; } // Do Trackbacks - if($trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft'")) { - foreach($trackbacks as $trackback) { - echo "Trackback : $trackback->ID
"; - do_trackbacks($trackback->ID); - } + while ($trackback = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' LIMIT 1")) { + echo "Trackback : $trackback->ID
"; + do_trackbacks($trackback->ID); } }