WordPress XML-RPC – Document is truncated because of UTF-8 BOM?

I have recently discovered that a site using XML-RPC to display a list of recent wordpress posts has stopped working. Upon digging into the XML-RPC respsone, I see that the last tag is truncated:

  </params>
  </methodRespons

I had a quick Google, and noticed that someone else had a similar issue, but the ticket was closed as it wasn’t deemed a WordPress issue:
http://core.trac.wordpress.org/ticket/6701

Read More

So, how come my XML is suddenly being sent with the BOM? I checked the class-IXR.php file and see everything looks normal:

    $xml = '<?xml version="1.0"?>'."n".$xml;
    $length = strlen($xml);
    header('Connection: close');
    header('Content-Length: '.$length);
    header('Content-Type: text/xml;charset=utf-8');
    header('Date: '.date('r'));
    echo $xml;
    exit;

I suppose I could hack the file to increase the content-length as a quick fix, but wondering why this has suddenly started happening.

Related posts

Leave a Reply

1 comment

  1. I had the same issue.
    It turned out that a single file had been been saved with UTF8-BOM encoding instead of UTF8 encoding.
    In case you encounter this, check the encoding on all files, especially recently installed or updated plugins or themes.
    Also if you make edits in the files directly, always use an encoding aware text editor .