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
This commit is contained in:
ryan 2005-09-02 16:56:28 +00:00
parent c7771dcaaf
commit 2844d3a71c
4 changed files with 62 additions and 4 deletions

View File

@ -6,7 +6,7 @@
</p>
</div>
<?php check_for_pings(); ?>
<?php do_action('admin_footer', ''); ?>
</body>

View File

@ -0,0 +1,37 @@
<?php
require_once('admin.php');
if ( ! current_user_can('edit_posts') )
die ("Cheatin' uh?");
echo '/* No Styles Here */';
register_shutdown_function('execute_all_pings');
//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<br/>";
$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<br/>";
$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<br/>";
do_trackback($trackback->ID);
}
}
}
?>

View File

@ -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();

View File

@ -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 '<iframe src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
}
function do_enclose( $content, $post_ID ) {
global $wp_version, $wpdb;
include_once (ABSPATH . WPINC . '/class-IXR.php');