http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96655

Revision: 96655
Author:   catrope
Date:     2011-09-09 11:28:00 +0000 (Fri, 09 Sep 2011)
Log Message:
-----------
Commit live hack: pass XML_PARSE_HUGE (code uses 1 << 19 because the constant 
isn't available for some reason) into DOMDocument::loadXML() if the first call 
to loadXML() failed. This prevents newer versions of libxml2 from throwing a 
warning and messing up when the XML contains structures that are nested more 
than 256 levels deep. RELEASE-NOTES added to the 1.18 file, tagging this for 
backporting to 1.18 too.

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.

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.18
    trunk/phase3/includes/parser/Preprocessor_DOM.php

Modified: trunk/phase3/RELEASE-NOTES-1.18
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.18     2011-09-09 11:11:22 UTC (rev 96654)
+++ trunk/phase3/RELEASE-NOTES-1.18     2011-09-09 11:28:00 UTC (rev 96655)
@@ -444,6 +444,8 @@
   #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.

Modified: trunk/phase3/includes/parser/Preprocessor_DOM.php
===================================================================
--- trunk/phase3/includes/parser/Preprocessor_DOM.php   2011-09-09 11:11:22 UTC 
(rev 96654)
+++ trunk/phase3/includes/parser/Preprocessor_DOM.php   2011-09-09 11:28:00 UTC 
(rev 96655)
@@ -155,7 +155,8 @@
                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' );
                        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to