JoeBlogs icon indicating copy to clipboard operation
JoeBlogs copied to clipboard

WordPress metaweblog.getRecentPosts returns string for postid

Open kevininspace opened this issue 12 years ago • 8 comments

The recent versions (since when?) of WordPress return a string for the postid in the XmlRpcPost struct. Strangely, returning a single post with metaweblog.getPost (or simply GetPost() method in JoeBlogs) retains the int for postid.

I've made a fork with some temporary code which properly casts the string to an int, but I think this is probably temporary in the WordPress code.

The code which returns the array in WordPress is in /wp-includes/class-wp-xmlrpc-server.php in mw_getRecentPosts and mw_getPost respectively.

kevininspace avatar Apr 25 '12 20:04 kevininspace

I've started hitting this myself. I was hitting it with WordPress 3.2, updated to 3.4.1, and I'm still hitting it. I'm having trouble finding a definitive place that defines that types in the returned struct, but a place using the same CookComputing XmlRpc library shows postid as string:

http://www.joeuser.com/api/MetaWeblog.axd#FullPost

jamesmanning avatar Jul 25 '12 18:07 jamesmanning

FWIW, WordPress specifically calls the postid out as a string in the returned struct, so it seems like this is By Design on their side and a code change needed in JoeBlogs (changing that member of the struct)

http://codex.wordpress.org/XML-RPC_MetaWeblog_API#metaWeblog.getPost

jamesmanning avatar Jul 25 '12 19:07 jamesmanning

I am having similar issues:

When calling method getrecentPosts(x); and getPages(); wordpress is returning string values for postid and pageid, where as your wrapper is expecting an integer.

RichardMacarthy avatar Jul 27 '12 12:07 RichardMacarthy

Sorry for taking so long to reply-

Hmm... Do we know if it was an int in previous versions of WP, and now is a string?

alexjamesbrown avatar Aug 07 '12 13:08 alexjamesbrown

@kevininspace feel free to pull request your changes

alexjamesbrown avatar Aug 07 '12 13:08 alexjamesbrown

Hi Alex thanks for your reply.

I have not been using XMLRPC for very long with Wordpress so I am unsure whether it used to be an int. I have downloaded your souce code and tried to update the files, but as you are using the Post class in so many places, this breaks for some methods and fixes for others, because some expect int and some string (nightmare).

I ended up creating my own class/method in the end.

Regards.

Richard.

RichardMacarthy avatar Aug 07 '12 13:08 RichardMacarthy

@alexjamesbrown I'll clean up my code and put a pull request this week. (New baby, can't be more precise than that!) While I'm at it, I'll check that it works with the new XML-RPC class just released with 3.4.

@RichardMacarthy @alexjamesbrown From my research, it appears it was an int, but a long time ago. I've been on the WordPress dev forums trying to explain this bug. It's been acknowledged but the devs don't want to fix it because it would break other clients. I've been back and forth on it but it seems like they've moved on.

kevininspace avatar Aug 13 '12 16:08 kevininspace

Great, thank you (and congrats!)

Yeah.. I'm going to need to tidy up / change getCategories / tags etc.. since wp changed all this to taxonomies

alexjamesbrown avatar Aug 13 '12 16:08 alexjamesbrown