XMLRPC Patch for WordPress 2.9.1

The latest release of WordPress 2.9.1 has a minor bug in the xmlrpc.php file which prevents the user from creating a new post remotely. There are quite a lot of issues with the xmlrpc.php, one being that the xml returned is not well-formed and the other is calling an method on an array.
I ran across these issues when I was trying to import some posts into WordPress using XMLRPC with Zend_XmlRpc_Client.

Anyway, the patch here will allow you to insert the post:

Index: xmlrpc.php
@@ -2195,13 +2195,16 @@

// Do some timestamp voodoo
if ( !empty( $content_struct['date_created_gmt'] ) )
- $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
+ $dateCreated = $content_struct['date_created_gmt'];
elseif ( !empty( $content_struct['dateCreated']) )
- $dateCreated = $content_struct['dateCreated']->getIso();
+ $dateCreated = $content_struct['dateCreated'];

if ( !empty( $dateCreated ) ) {
- $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ $dateIXR = new IXR_Date(strtotime($dateCreated));
+ $dateCreated = $dateIXR->getIso();
+ $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+ $post_date_gmt = iso8601_to_datetime($dateCreated. "Z", GMT);
} else {
$post_date = current_time('mysql');
$post_date_gmt = current_time('mysql', 1);

Copy the above code to a file, call it xmlrpc.patch. To patch the content of xmlrpc.php which is located say under directory public:

~/public$ patch -p0 < xmlrpc.patch

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.