WordPress 2.9 – XML-RPC and AtomPub Changes

Just in time for Christmas WordPress 2.9 is out. Here’s what has changed in the XML-RPC and AtomPub APIs since 2.8.6:

XML-RPC

  • Expose user registration option via wp.getOptions/wp.setOptions ( ticket #10454 )
  • Fix bug in wp.getComment that reported spam comments with a status of hold ( ticket #10510 )
  • Adjust how the XML-RPC server is activated so that the functions can be reused in other areas ( ticket #10513 )
  • Fix bug in setting optional number of pages arguments for wp.getPages ( ticket #10659 )
  • Reduced memory usage when processing requests ( ticket #10698 )

AtomPub

  • Fix a conflict with plugins that redefine wp_set_current_user() ( ticket #10938 )

If you are using the WordPress XML-RPC/AtomPub APIs in your software or service, or are just interested in this part of WordPress, please join the WordPress XML-RPC email list. Code changes and patches can be submitted via tickets at http://core.trac.wordpress.org/.

XML-RPC Types: Dates vs. Strings

The XML-RPC spec outlines 6 types: integer, boolean, string, double, date/time and base64. If you count struct and array as types then we go up to 8 types. The XML-RPC page on Wikipedia has examples of the XML tags for these data types.

One mistake that I’ve seen commonly made (and I’ve done it myself) is to confuse dates and strings. It’s easy to do, most databases for instance treat date input essentially as a string. So it might seem natural that a date would be encoded in XML-RPC as:

<string>19980717T14:08:55</string>

and expect the XML-RPC server to just know that it should be converting that value to a date/time. XML-RPC libraries massage the encoded values based on the XML tag though, so this gets treated as a string. The correct mark up for a date/time value would be:

<datetime.iso8601>19980717T14:08:55</datetime.iso8601>

An XML-RPC library will then put this into a correct date context for that specific programming language.

If you find that a date field in your XML-RPC request isn’t being processed correctly take a look at the raw XML, you may actually be passing it as a string. When a problem comes up spending a minute to verify the XML tag can save you a bigger headache later on.

WordPress 2.8.1 – XML-RPC and AtomPub Changes

The 2.8.1 release of WordPress is now available. This is mostly a bug fix release so there are only a few small changes in the area of XML-RPC and no changes in AtomPub:

  • metaWeblog.getPost now returns the correct value for the date_created_gmt field for draft posts ( ticket #10244 )
  • RSD API endpoint URLs now use HTTPS if FORCE_SSL_ADMIN or FORCE_SSL_LOGIN is defined and true ( ticket #10330 )