Patch for WordPress 2.0 trackback issue

After upgrading to wordpress 2.0, I found the WP2.0 is failed to send trackback.

This issue is also confirmed by ijliao, priv, and Ah Knight’s Blog.

There has been a workaround in Ah Knight’s Blog for this issue.But even you clean up the “to_ping” field, you may encounter this issue again later. Instead of clean up the “to_ping” field times by times, I try to dig the bug out from the source.

The bug is intrduced by an infinite-loop condition located in wp-admin/execute-pings.php, which is implemented for “ping deley removed” feature in WordPress 2.0. If you have any un-sent and failed-to-sent trackbacks, this bug will cause the script continuously trying to send the first trackback in the “to_ping” field, and failed to process the other to_pings.

Which conditions will cause “to_ping” fail to be sent?

First, it occurs when the trackback url can’t be reached. Maybe the site has been closed, maybe he refuses receiving trackbacks. The url will remain in the “to_ping” field and make the infinite-loop triggered.

Second, there is another bug existed in wp-includes/function-post.php. When the content in “to_ping” field is nothing but some character like “\n”, the get_to_ping() function will return an empty array, then do_trackback() will just return nothing, let the “to_ping” field untouched. It will also cause the infinite-loop triggered.

I’ve make a patch for fixing these two can download them here(Or try the ZIP version). Make sure that you’ve put them into the correct dirs(wp-admin for execute-pings.php.diff and wp-includes for functions-post.php.diff) and applied the patch by executing following command:

patch functions-post.php functions-post.php.diff
patch execute-pings.php execute-pings.php.diff

Please don’t just rename the .php.diff to .php then upload them.

For those don’t know what the patch is, or don’t know how to use patch, please read the following:

I’ve made the patched file for your convenience. Now you can download the patched source in tgz format or ZIP format. All you need to do is just uploading and putting them into the correct dirs.
Hope the WordPress dev team fix the bugs(including pingback issue) in the next release/patch :) AFAIK, this patch has been put into the codebase of WordPress.

PS. A chinese version for this post can be found here.

The Patch has been merged into dev’s codebase since WP 2.0.1. Recommend to upgrade your WP to 2.0.2 if you are still using 2.0.
If you already use 2.0.1/2.0.2 please do not try to apply this patch.