Commit live hack: pass XML_PARSE_HUGE (code uses 1 << 19 because the constant isn...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 9 Sep 2011 11:28:00 +0000 (11:28 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 9 Sep 2011 11:28:00 +0000 (11:28 +0000)
We at Wikimedia never noticed this issue until we upgraded libxml2 on one of our servers as part of an OS upgrade, but apparently the interwebs knew about this since at least May 2010. Hat tip
 to http://deriksmith.livejournal.com/57617.html , where I found this fix.

RELEASE-NOTES-1.18
includes/parser/Preprocessor_DOM.php

index d011905..19daaa1 100644 (file)
@@ -444,6 +444,8 @@ production.
   #REDIRECT [[Foo]] is invalid JS
 * Tracking categories are no longer shown in footer for special pages
 * $wgOverrideSiteFeed no longer double escapes urls.
+* The preprocessor no longer fails with a PHP warning about XML_PARSE_HUGE when
+  processing complex pages using newer versions of libxml2.
 
 === API changes in 1.18 ===
 * BREAKING CHANGE: action=watch now requires POST and token.
index dcda8a2..e6c1d67 100644 (file)
@@ -155,7 +155,8 @@ class Preprocessor_DOM implements Preprocessor {
                if ( !$result ) {
                        // Try running the XML through UtfNormal to get rid of invalid characters
                        $xml = UtfNormal::cleanUp( $xml );
-                       $result = $dom->loadXML( $xml );
+                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
+                       $result = $dom->loadXML( $xml, 1 << 19 );
                        if ( !$result ) {
                                throw new MWException( __METHOD__.' generated invalid XML' );
                        }