alexjamesbrown / JoeBlogs

Wordpress / Metaweblog API Wrapper
53 stars 40 forks source link

WordPress metaweblog.getRecentPosts returns string for postid #13

Open kevininspace opened 12 years ago

kevininspace commented 12 years ago

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.

jamesmanning commented 12 years ago

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 commented 12 years ago

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

RichardMacarthy commented 12 years ago

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.

alexjamesbrown commented 12 years ago

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 commented 12 years ago

@kevininspace feel free to pull request your changes

RichardMacarthy commented 12 years ago

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.

kevininspace commented 12 years ago

@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.

alexjamesbrown commented 12 years ago

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