From 2844d3a71cbe4eb23818c8ea28c8aed1efe0a793 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 2 Sep 2005 16:56:28 +0000 Subject: [PATCH] Move pings out-of-band to speed up posting. Props to Owen. fixes #1644 git-svn-id: http://svn.automattic.com/wordpress/trunk@2833 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-footer.php | 2 +- wp-admin/execute-pings.php | 37 ++++++++++++++++++++++++++++++++++ wp-includes/functions-post.php | 14 ++++++++++--- wp-includes/functions.php | 13 ++++++++++++ 4 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 wp-admin/execute-pings.php diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index d4ac15bc3..1593437c9 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -6,7 +6,7 @@

- + diff --git a/wp-admin/execute-pings.php b/wp-admin/execute-pings.php new file mode 100644 index 000000000..cb2ec5f38 --- /dev/null +++ b/wp-admin/execute-pings.php @@ -0,0 +1,37 @@ +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';"); + } + } + // 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';"); + } + } + // Do Trackbacks + if($trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != ''")) { + foreach($trackbacks as $trackback) { + //echo "trackback : $trackback->ID
"; + do_trackback($trackback->ID); + } + } +} +?> \ No newline at end of file diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index f79be3e3c..e5ddbfd9f 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -155,9 +155,17 @@ function wp_insert_post($postarr = array()) { if ($post_status == 'publish') { do_action('publish_post', $post_ID); if ($post_pingback) - register_shutdown_function('pingback', $content, $post_ID); - register_shutdown_function('do_enclose', $content, $post_ID ); - register_shutdown_function('do_trackbacks', $post_ID); + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_pingme','1') + "); + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_encloseme','1') + "); + //register_shutdown_function('do_trackbacks', $post_ID); } else if ($post_status == 'static') { generate_page_rewrite_rules(); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 08b2ddd63..fceaf3668 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -827,6 +827,19 @@ function debug_fclose($fp) { } } +function check_for_pings() { + global $wpdb; + $doping = false; + if($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1")) { + $doping = true; + } + if($wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1")) { + $doping = true; + } + if($doping) + echo ''; +} + function do_enclose( $content, $post_ID ) { global $wp_version, $wpdb; include_once (ABSPATH . WPINC . '/class-IXR.php');