Ticket #2092: one-ping-only.diff
File one-ping-only.diff, 6.2 KB (added by , 19 years ago) |
---|
-
wp-includes/functions-post.php
182 182 do_action('publish_post', $post_ID); 183 183 184 184 if ( !defined('WP_IMPORTING') ) { 185 if ( $post_pingback ) 186 $result = $wpdb->query(" 187 INSERT INTO $wpdb->postmeta 188 (post_id,meta_key,meta_value) 189 VALUES ('$post_ID','_pingme','1') 190 "); 191 $result = $wpdb->query(" 192 INSERT INTO $wpdb->postmeta 193 (post_id,meta_key,meta_value) 194 VALUES ('$post_ID','_encloseme','1') 195 "); 185 if ( $post_pingback ) { 186 $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE ID = $post_ID AND meta_key = '_pingme'"); 187 $result = $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_ID','_pingme','$post_date_gmt')"); 188 } 189 $result = $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_ID','_encloseme','1')"); 196 190 spawn_pinger(); 197 191 } 192 } elseif ( $previous_status == 'publish' ) { 193 // Remove scheduled pings (in case you unpublish a future post) 194 $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE ID = $post_ID AND meta_key = '_pingme'"); 198 195 } else if ($post_status == 'static') { 199 196 generate_page_rewrite_rules(); 200 197 -
wp-includes/classes.php
670 670 671 671 update_post_caches($this->posts); 672 672 673 if ( have_pings_in_cache() ) 674 spawn_pinger(1); 675 673 676 $this->posts = apply_filters('the_posts', $this->posts); 674 677 $this->post_count = count($this->posts); 675 678 if ($this->post_count > 0) { -
wp-includes/functions.php
980 980 } 981 981 } 982 982 983 function spawn_pinger() { 984 global $wpdb; 985 $doping = false; 986 if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") ) 983 function have_pings_in_cache() { 984 global $post_cache, $post_meta_cache; 985 986 $ping = false; 987 988 if ( count($post_cache) ) { 989 foreach ($post_cache as $post) 990 if ( (trim($post->to_ping) != '') && (strtotime($post->post_date_gmt) <= gmdate('U')) ) { 991 $ping = true; 992 break; 993 } 994 995 reset($post_cache); 996 } 997 998 if ( count($post_meta_cache) ) { 999 foreach ($post_meta_cache as $meta) 1000 if ( isset($meta['_pingme']) && (strtotime($meta['_pingme']) <= gmdate('U')) ) { 1001 $ping = true; 1002 break; 1003 } 1004 1005 reset($post_meta_cache); 1006 } 1007 1008 return $ping; 1009 } 1010 1011 function spawn_pinger($doping = false) { 1012 global $wpdb, $spawned_pinger; 1013 1014 if ( $spawned_pinger > $doping ) 1015 return; 1016 1017 $now = gmdate('Y-m-d H:i:59'); 1018 1019 if ( !$doping && $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_date_gmt <= '$now' LIMIT 1") ) 987 1020 $doping = true; 988 1021 989 if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme'OR meta_key = '_encloseme' LIMIT 1") )1022 if ( !$doping && $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE (meta_key = '_pingme' AND meta_value <= '$now') OR meta_key = '_encloseme' LIMIT 1") ) 990 1023 $doping = true; 991 1024 992 1025 if ( $doping ) { 993 1026 $ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php'; 994 1027 $parts = parse_url($ping_url); 995 1028 $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); 1029 996 1030 if ( $argyle ) 997 1031 fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n"); 1032 1033 ++$spawned_pinger; 998 1034 } 999 1035 } 1000 1036 -
wp-admin/execute-pings.php
6 6 7 7 function execute_all_pings() { 8 8 global $wpdb; 9 10 $now = gmdate('Y-m-d H:i:59'); 11 9 12 // Do pingbacks 10 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';")) { 11 foreach($pings as $ping) { 12 pingback($ping->post_content, $ping->ID); 13 echo "Pingback: $ping->post_title : $ping->ID<br/>"; 14 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 15 } 13 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' AND {$wpdb->postmeta}.meta_value <= '$now' LIMIT 1")) { 14 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 15 pingback($ping->post_content, $ping->ID); 16 echo "Pingback: $ping->post_title : $ping->ID<br/>"; 16 17 } 17 18 // Do Enclosures 18 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';")) { 19 foreach($enclosures as $enclosure) { 20 do_enclose($enclosure->post_content, $enclosure->ID); 21 echo "Enclosure: $enclosure->post_title : $enclosure->ID<br/>"; 22 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 23 } 19 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")) { 20 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 21 do_enclose($enclosure->post_content, $enclosure->ID); 22 echo "Enclosure: $enclosure->post_title : $enclosure->ID<br/>"; 24 23 } 25 24 // Do Trackbacks 26 if($trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft'")) { 27 foreach($trackbacks as $trackback) { 28 echo "Trackback : $trackback->ID<br/>"; 29 do_trackbacks($trackback->ID); 30 } 25 while ($trackback = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' ANT post_date_gmt <= '$now' LIMIT 1")) { 26 echo "Trackback : $trackback->ID<br/>"; 27 do_trackbacks($trackback->ID); 31 28 } 32 29 } 33 30