Sometimes on importing I get the following message:

"Excessive depth in document: 256 use XML_PARSE_HUGE"

Reading here suggests I can use the XML_PARSE_HUGE option, but I'm not sure where to do this in the code.

Any suggestions?

Comments

twistor’s picture

Title: How to use XML_PARSE_HUGE » Add support for XML_PARSE_HUGE
Category: support » feature

You would add it in FeedsXPathParserXML.inc in this line:
$success = $doc->loadXML($raw);

Changing this to a feature request as someone else might want to implement this.

absoludo’s picture

I created the requested patch but am not able to upload the patch on Drupal.org

Therefore I supply the raw patch code here

diff --git a/FeedsXPathParserXML.inc b/FeedsXPathParserXML.inc
index 85eece8..9b8e850 100644
--- a/FeedsXPathParserXML.inc
+++ b/FeedsXPathParserXML.inc
@@ -26,7 +26,15 @@ class FeedsXPathParserXML extends FeedsXPathParserBase {
     }
     $doc = new DOMDocument();
     $use = $this->errorStart();
-    $success = $doc->loadXML($raw);
+    // Check if filesize is larger than 10MB and PHP version is higher than 5.2.
+    // If these criteria are met the constant LIBXML_PARSEHUGE needs to be
+    // passed.
+    if (drupal_strlen($raw) >= 1048576 && version_compare(phpversion(), '5.2', '>')) {
+      $success = $doc->loadXML($raw, LIBXML_PARSEHUGE);
+    }
+    else {
+      $success = $doc->loadXML($raw);
+    }
     unset($raw);
     $this->errorStop($use, $source_config['exp']['errors']);
     if (!$success) {
absoludo’s picture

Issue summary: View changes
StatusFileSize
new823 bytes

I just noticed the "Upload new files" link which I read as a part of the issue's body text.
Here is the uploaded patch.
I also committed it to git.

twistor’s picture

Status: Active » Needs work

strlen() isn't the correct check here. LIBXML_PARSEHUGE raises the limits on the size of text nodes, as well as, the depth of the document.

twistor’s picture

Title: Add support for XML_PARSE_HUGE » Add support for XML_PARSE_HUGE.
Project: Feeds XPath Parser » Feeds Extensible Parsers
Component: Code » XML parser
Assigned: Unassigned » twistor

We should probably just add this option if it is supported. Are there drawbacks?

Check needs to take into account: Only available in Libxml >= 2.7.0 (as of PHP >= 5.3.2 and PHP >= 5.2.12)

twistor’s picture

Status: Needs work » Needs review
StatusFileSize
new1.93 KB

Status: Needs review » Needs work

The last submitted patch, 6: feeds_ex-parse-huge-1924888-6.patch, failed testing.

twistor’s picture

Status: Needs work » Needs review
StatusFileSize
new1.93 KB

  • twistor committed 246088d on 7.x-1.x
    Issue #1924888 by twistor, absoludo | swfindlay: Added support for...
twistor’s picture

Assigned: twistor » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.