From 73ef6597634d1bde8798f109112eb3805790c751 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 30 Mar 2006 07:36:54 +0000 Subject: [PATCH] Future post pinging and cron fixups from masquerade. fixes #2469 git-svn-id: http://svn.automattic.com/wordpress/trunk@3663 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-footer.php | 6 ------ wp-admin/execute-pings.php | 27 --------------------------- wp-includes/default-filters.php | 1 + wp-includes/functions-post.php | 28 +++++++++++++++++++++++++++- wp-includes/functions.php | 21 --------------------- 5 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 wp-admin/execute-pings.php diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index e660be287f..783be91d06 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -9,11 +9,5 @@ -'; -} -?> - diff --git a/wp-admin/execute-pings.php b/wp-admin/execute-pings.php deleted file mode 100644 index a807223c6f..0000000000 --- a/wp-admin/execute-pings.php +++ /dev/null @@ -1,27 +0,0 @@ -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); -} - -// Do Enclosures -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); -} - -// Do Trackbacks -$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); -if ( is_array($trackbacks) ) { - foreach ( $trackbacks as $trackback ) { - do_trackbacks($trackback->ID); - } -} - -generic_ping(); - -?> diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 32599bfcf4..a3a4e20ff4 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -92,4 +92,5 @@ add_action('do_feed_rdf', 'do_feed_rdf', 10, 1); add_action('do_feed_rss', 'do_feed_rss', 10, 1); add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); add_action('do_feed_atom', 'do_feed_atom', 10, 1); +add_action('do_pings', 'do_all_pings', 10, 1); ?> diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index c6e3df2760..800c6b6074 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -199,7 +199,7 @@ function wp_insert_post($postarr = array()) { (post_id,meta_key,meta_value) VALUES ('$post_ID','_encloseme','1') "); - spawn_pinger(); + wp_schedule_single_event(time(), 'do_pings'); } } else if ($post_type == 'page') { wp_cache_delete('all_page_ids', 'pages'); @@ -1002,4 +1002,30 @@ function wp_upload_bits($name, $type, $bits) { return array('file' => $new_file, 'url' => $url, 'error' => false); } +function do_all_pings() { + global $wpdb; + + // Do pingbacks + 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); + } + + // Do Enclosures + 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); + } + + // Do Trackbacks + $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); + if ( is_array($trackbacks) ) { + foreach ( $trackbacks as $trackback ) { + do_trackbacks($trackback->ID); + } + } + + //Do Update Services/Generic Pings + generic_ping(); +} ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 283375013a..9c56a35c58 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1119,27 +1119,6 @@ function debug_fclose($fp) { } } -function spawn_pinger() { - 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 ( substr(php_sapi_name(), 0, 3) == 'cgi' ) - return $doping; - - if ( $doping ) { - $ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php'; - $parts = parse_url($ping_url); - $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); - if ( $argyle ) - fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n"); - } -} - function do_enclose( $content, $post_ID ) { global $wp_version, $wpdb; include_once (ABSPATH . WPINC . '/class-IXR.php');