Ticket #2092: future-pings.diff
| File future-pings.diff, 6.3 KB (added by skeltoac, 7 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
1 1 <?php 2 3 ignore_user_abort(true); 4 2 5 require_once('../wp-config.php'); 3 6 4 register_shutdown_function('execute_all_pings'); 5 //execute_all_pings(); 7 $now = gmdate('Y-m-d H:i:59'); 6 8 7 function execute_all_pings() { 8 global $wpdb; 9 // Do pingbacks 10 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")) { 11 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 12 pingback($ping->post_content, $ping->ID); 13 echo "Pingback: $ping->post_title : $ping->ID<br/>"; 14 } 15 // Do Enclosures 16 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")) { 17 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 18 do_enclose($enclosure->post_content, $enclosure->ID); 19 echo "Enclosure: $enclosure->post_title : $enclosure->ID<br/>"; 20 } 21 // Do Trackbacks 22 while ($trackback = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' LIMIT 1")) { 23 echo "Trackback : $trackback->ID<br/>"; 24 do_trackbacks($trackback->ID); 25 } 9 // Do pingbacks 10 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")) { 11 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 12 pingback($ping->post_content, $ping->ID); 13 echo "Pingback: $ping->post_title : $ping->ID<br/>"; 26 14 } 27 15 28 _e('Done.'); 16 // Do Enclosures 17 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")) { 18 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 19 do_enclose($enclosure->post_content, $enclosure->ID); 20 echo "Enclosure: $enclosure->post_title : $enclosure->ID<br/>"; 21 } 29 22 23 // Do Trackbacks 24 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")) { 25 echo "Trackback : $trackback->ID<br/>"; 26 do_trackbacks($trackback->ID); 27 } 28 30 29 ?>
