开发者

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-RP开发者_Python百科C 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

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.


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 .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜