Supertext Home
Chief of the System Blog

Archive for the 'Wordpress' Category


Wordpress XML-RPC Issues

Wednesday, May 5th, 2010

After upgrading my wordpress blog I could not connect my Windows Live Writer anymore. Funny enough it will worked with my other blog (blog.supertext.ch). The only difference that I could find, was that remy.supertext.ch was configured to use iso-8859-1 and blog.supertext.ch used utf-8. But changing that did not actually help. Could be that the issue is some info that is still in the database.

Using the Wordpress iPhone App, I got the following error:

NSXMLParserErrorDomain error 73

Does not really help either. But I found some posts, suggesting all kind of things that all didn’t apply or work.

Now, getting a little desperate, I installed Fiddler (which is really an awesome tool) and discovered that if I rerun the rpc call that Windows Live Writer is doing, I get a Content-Length mismatch Error:

image

Here is the request in raw form, you can try it yourself to see what results you get. Password/Username do not matter for the test, but you have to set the POST and Host value correctly:

POST http://blog.yourhost.ch/xmlrpc.php HTTP/1.1
Accept: */*
Accept-Language: en-US, en, *
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Writer 1.0)
Content-Type: text/xml
Host: blog.yourhost.ch
Content-Length: 491
Connection: Close

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
 <methodName>blogger.getUsersBlogs</methodName>
 <params>
  <param>
   <value>
    <string>ffffffabffffff716</string>
   </value>
  </param>
  <param>
   <value>
    <string>admin</string>
   </value>
  </param>
  <param>
   <value>
    <string>password</string>
   </value>
  </param>
 </params>
</methodCall>

I don’t really have an idea on how to fix this for real, but what helped is to just add 2 to the length of the response. Edit the class-IXR.php file from the wp-includes directory on line 396. I’m using Wordpress Version 2.9.2

function output($xml) {
    $xml = '<?xml version="1.0"?>'."\n".$xml;
    $length = strlen($xml);
    header('Connection: close');
    header('Content-Length: '.$length  + 2);
    //+2 Solves the Live Writer issue
    header('Content-Type: text/xml');
    header('Date: '.date('r'));
    echo $xml;
    exit;
}

Just FYI:
I’m using IIS 6.0 on Windows 2003.


Wordpress upgrade to 2.6 deletes all Categories

Monday, August 4th, 2008

After not having updated Wordpress for a while (we were still on 2.3), the new Wordpress iPhone Application convinced us that it was about time.

Unfortunately, all my categories were missing after the upgrade. Seems like the wp_categories table got removed an replaced by wp_terms and wp_term_taxonomy. The entries are still there, just without name and descriptions.

Fortunately there are ways to fix it (if you have a backup, harhar).

David Cumps wrote a nice post about how to fix it manually, but if you have lots of Categories, you can do it automatically too (if you prepare of it).

First step (before the upgrade) is to save a version of the wp_categories table:

mysqldump -uUsername -pPassword wordpress_db
wp_categories > wp_categories.sql


After the upgrade you have to play it back and run the following two queries:

mysql -uUsername -pPassword
wordpress_db < wp_categories.sql


UPDATE wp_terms, wp_categories
SET wp_terms.name = wp_categories.cat_name,
wp_terms.slug = wp_categories.category_nicename
WHERE wp_terms.term_id = wp_categories.cat_ID


UPDATE wp_term_taxonomy, wp_categories
SET wp_term_taxonomy.description =
wp_categories.category_description
WHERE wp_term_taxonomy.term_id = wp_categories.cat_ID


If you didn’t make a backup of the wp_categories table, you can just load the whole backup again and give it a different name. When you run the 2 queries, just prefix the table names with the name of the backup DB.

Update: If you have subcategories, you can try the query I posted in my comment below. I didn’t actually try it myself, so be careful.

Supertext

Blog Home

News
Contact
Newsletter
Portrait
Network
Team
Customer
Partner
Press
Examples

Search the blog
Facebook
Twitter