1# This patch is created from https://github.com/easyrdf/easyrdf/pull/370
2# It tries to improve the Report Import agent without updating the easyrdf
3# from 0.9.0 to latest version due to PHP version constraints.
4#
5# The copyrights are help by the respective authors (see
6# https://github.com/easyrdf/easyrdf/blob/master/LICENSE.md).
7
8--- vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php	2020-09-08 17:14:43.328912848 +0530
9+++ vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php	2021-01-27 14:06:18.391440952 +0530
10@@ -795,14 +795,22 @@
11         /* xml parser */
12         $this->initXMLParser();
13
14-        /* parse */
15-        if (!xml_parse($this->xmlParser, $data, false)) {
16+        /* split into 1MB chunks, so XML parser can cope */
17+        $chunkSize = 1000000;
18+        $length = strlen($data);
19+        for ($pos=0; $pos < $length; $pos += $chunkSize) {
20+          $chunk = substr($data, $pos, $chunkSize);
21+          $isLast = ($pos + $chunkSize > $length);
22+
23+          /* Parse the chunk */
24+          if (!xml_parse($this->xmlParser, $chunk, $isLast)) {
25             $message = xml_error_string(xml_get_error_code($this->xmlParser));
26             throw new EasyRdf_Parser_Exception(
27-                'XML error: "' . $message . '"',
28-                xml_get_current_line_number($this->xmlParser),
29-                xml_get_current_column_number($this->xmlParser)
30-            );
31+              'XML error: "' . $message . '"',
32+              xml_get_current_line_number($this->xmlParser),
33+              xml_get_current_column_number($this->xmlParser)
34+              );
35+          }
36         }
37
38         xml_parser_free($this->xmlParser);
39