Plugin – LibXML2 Fix

Intro

Some versions of libxml2 didn’t work properly with PHP, resulting in brackets being stripped from XML. This showed up most often in XML-RPC requests being mangled. This was ultimately resolved with the release of PHP 5.2.9 and libxml2 2.7.3. As of today (16 March 2009) there are still hosts that are running versions of libxml2 and PHP that are known to be broken. To help the ease the pain of WordPress users stuck in this unfortunate situation I wrote a plugin that includes a common hack to work around this problem for XML-RPC requests.

Kudos to Peter Westwood on suggesting a technique to make this work as a plugin instead of hard coding it into WordPress.

History

WordPress ticket #7771

My blog posts on the subject:

Plugin

The plugin is available for download at http://wordpress.org/extend/plugins/libxml2-fix/.

Change Log

0.1 – 17 March 2009

  • Initial release

0.2 – 15 April 2009

  • Enable the fix even if the libxml2 version is 2.7.3 if the PHP is also less than 5.2.9

0.2.2 – 15 April 2009

  • Fix typo in version 0.2 (noticed by Rein)

0.2.3 – 29 December 2009

  • Add 2.6.27 to the list of libxml versions that trigger the fix

45 Comments »

 
  • Brilliant.

    Good to see the patch converted to a plugin so easily!

  • Ajay says:

    Fantastic release Joseph :)

  • [...] kan het wordpress ticket en de fix worden [...]

  • [...] blogs, experimented with changing the php sourcecode directly I found a simple and neat solution. Joseph Scott created a wordpress plugin which is also available at Wordpress.org to fix the LibXML2 problem [...]

  • Paul says:

    If I have tried the plugin and it still doesn’t work, is my only option to lean on the shared host provider to try and get iPhone posting to work?

    • Joseph Scott says:

      I’d be curious to know why it doesn’t work. Can you look at the output of phpinfo(); and tell me what version of PHP and libxml2 your system is using?

    • Abishai says:

      In my case the plugin didn’t work because the combination php 5.2.8 libxml 2.7.3 in my hosted server still removes brackets. As a quick and dirty fix I just added:

      || LIBXML_DOTTED_VERSION == ‘2.7.3′

      to the condition in the plugin.

      It works until I get php updated to 5.2.9

      • Joseph Scott says:

        Yes, I believe that is what’s happening for people who say the plugin isn’t working right. I’m going to update it check for libxml2 2.7.3 and PHP versions lower than 5.2.9.

  • [...] there’s a new plugin for this problem created by Joseph Scott One of the developers of Wordpress. I’ve tested this plugin and It works. Incase the plugin does [...]

  • Avinash says:

    Scott thanks a lot your plugin worked, fixed the problem that I’ve been facing this problem since few months.

  • [...] 引起这一问题的原因主要是WordPress的XML-RPC模式造成的。Joseph Scott,WordPress的开发者已经公布了一款插件LibXML2 Fix来解决这一问题。遇到类似情况的朋友不妨试试。 [...]

  • VanUdin says:

    Thanks, at last my problem was fixed…

  • rein says:

    I found typo which causes 500 internal server error in new version(0.2) of plugin.

    I think, 21th line should be version_compare should be not ‘version_comapare’.

  • [...] LibXML2 Fi: Sirve para solucionar un bug que le pasa a mucha gente (yo incluido) que no reconoce el html bien cuando se postea desde windows live writer. [...]

  • Jason says:

    Hi Joseph (& all),

    I’m a non-techie and appreciate the plug-in, but where do I place the libmxl2 php file???

    …in the “plug-ins” folder for Wordpress – I have WP running off the server where I host my site.

    Please let me know. Thanks in advance!

    Jason

  • Domus says:

    Hi Joseph!
    I have searched the internet for the solution of their problems with Windows Live Writer (I have to load a list of more than 100 titles – showing an error “Invalid response document returned from XmlRpc server” and headers are not loaded. Advised to put your plugin. I found it on WP 2.7. 1. Now, with the publication of WLW text is published as: “blockquote p align =” justify “Microsoft has launched a search engine a href =” http://www.bing.com/?cc=ru “rel =” nofollow “Bing / a” but it should show as “Microsoft has launched a search engine Bing”. I made a plugin inactive, but still published with errors. now have to publish the records of the visual editor of WP and I’m not entirely comfortable. You will be able to help me in this problem? Thanks in advance!
    p.s. hosting is now version libxml2 2.7.2

  • Jeff says:

    Joseph,
    This is great. Thanks so much.

    In my particular case, it isn’t that my ISP isn’t updating – but the yum packages are out of date and I’d like to keep from building from source if at all possible on my servers.

    Really appreciate it.

  • davidconnell says:

    Just wanted to give you a quick thanks for this great solution to a problem that has been bugging me for quite some time. One of the reasons I wanted to work with WordPress is because I could post from anywhere anytime. This issue was seriously cramping my style and locking me into the wordpress dashboard.

    Thanks so much for a great and easy fix.

  • Emma says:

    Hi
    I been trying to work out why I was having the angle bracket stripping scenario … and have ended up here.

    i’ve just checked the PHP & LIBXML versions on my server & they’re:

    PHP: 5.2.6
    LIBXML: 2.6.26

    which, from reading the above would suggest that it’s not a version that causes the problems. However, just in case, I edited the plugin to change one of the 2.7.x lines to 2.6.26 … to no avail.

    Other than persuading the Uni to upgrade (…) what other suggestions do people have?

    • Joseph Scott says:

      Probably worth making sure there’s not something else that is stripping brackets. Watch the HTTP traffic for the XML-RPC requests and make sure that the raw XML is getting to your server intact. Then narrow down where exactly the problem is happening.

      If it turns out that the number of versions of PHP+libxml that have problems is wider than we thought then we’ll need to find a way to deal with that.

      • Emma says:

        Hi Joseph
        Thanks for getting back to me; as a bit of numpty question – how to do I check the raw HTML is getting to the server OK? (I’ve had Scribefire/Flock etc., working fine in the past & they’re also affected by the same problem)

        • Joseph Scott says:

          Try logging the raw data on the server side before WordPress processes it.

          • Emma says:

            I’m afraid that’s a bit of a challenge to me … I suspect, though, that as Scribefire, Flock & Live Writer are all doing it & I used to be able to post fine from Flock, that the php versions are the problem (I know they have recently updated this server)

  • Hong says:

    Thanks! You made my day. It is because of people like you that, the Earth is still spinning today =D.

  • Hong says:

    Anyway, I managed to add my code into your code so your plugin is compatible with my host’s libxml. You could have a little gui to select libxml version. That will be handy. Just a suggestion ;)

    LIBXML_DOTTED_VERSION == ‘2.6.32′

    • Joseph Scott says:

      You are seeing the bracketing stripping problem with libxml version 2.6.32? From what I’d see the change had been introduced in 2.7. If we can confirm that problem exists in earlier versions then I’ll updated the plugin to cover those as well.

  • Emma says:

    I’ll get onto our Web team; however, for the time being, it could be useful for you to know that we’ve got libxml 2.6.26 & php 5.2.6

    Emma

  • [...] now discovered that it’s related to the versions of libxml. I’ve installed the plugin developed by Joseph Scott – though still not working, as we have a different version of [...]

  • narakrisna says:

    thanks Joseph, now I can take my deep breath and focus to increase my traffic and no tag dissapear anymore :)

  • Pierre says:

    Thanks for your plugin worked first time.

    Appreciate it

  • Allen says:

    Joseph, thanks for the plugin. It definitely fixed the issue. However, I noticed something today I believe is a side-effect of this problem and plugin. If I try to embed videos from youtube using Windows Live Writer, these never show up on the web page. Have you seen or heard of this before?

    • Joseph Scott says:

      Ultimately the best solution is always to use versions of PHP + libxml that don’t have this problem.

      As for Youtube videos not showing up afterwards I haven’t seen any reports of that. Do the embeds get completely stripped out, or are they mangled?

      • Allen says:

        Now I can’t reproduce the issue. :(
        I had deactivated and reactivated the plugin for testing and it appears to be working now.
        If I can get a repro again, I will let you know.

        Thanks!

      • Allen says:

        also, my ISP won’t update PHP. They told me they are using the currently supported version pf PHP by cPanel. Until cPanel says they can upgrade, they won’t. :(

  • Joseph Scott says:

    Sounds like the PHP+libxml combination are likely to blame then. Have you talked with the admin responsible for the server? If they do an update and then things start breaking then they should look at fixing it or consider undoing the update.