Maybe we should switch to XMLReader (another PHP core library)? It's a "pull parser" that only reads part of the XML file into memory at a time; whereas SimpleXML is a "DOM parser" that reads and process the entire XML file at once.
XMLReader is also using libxml on the back end, but it seems to go through a different interface that is specifically designed to minimize memory use, so the LIBXML_PARSEHUGE thing might not matter. -- You received this bug notification because you are a member of Mahara Contributors, which is subscribed to Mahara. Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it! https://bugs.launchpad.net/bugs/1422837 Title: XML RPC simpleXML limits payload size Status in Mahara: Confirmed Status in Mahara 16.10 series: Confirmed Bug description: Operating System: Ubuntu 14.04.1 LTS Mahara version: 1.9.3 Database: mysql Browser: chrome 40.0.2214.111 ------------------------------ Steps to reproduce - you need a system capable of XMLRPC communication with Mahara (e.g. Moodle) 1) With Moodle - set up mahara networking / portfolios. 2) Open a course with a forum 3) Add 2 entries. One with an attachment under 5 MB. One with an attachment over 5 MB. On Each click "Export to portfolio" in the bottom. 4) Go through the screens to start export - ask it to do it now (i.e. not wait for cron). 5) Check the Mahara site to see what made it through successfully. ------------------------------ simpleXML may not be the best parser for XMLRPC payloads in api/xmlrpc/lib.php function parse_payload($payload) { try { $xml = new SimpleXMLElement($payload); return $xml; } catch (Exception $e) { throw new MaharaException('Encrypted payload is not a valid XML document', 6002); } } This means if you send a large file (in our tests greater than approx 7mb) base 64 encoded over XMLRPC it will fail to parse. It didn't seem to make any difference if we increased the memory limit to 800M in php.ini or even by setting the php memory limit to 800M via PHP ini_set in function parse_payload - this suggests that there is a limit to what SimpleXML can handle regardless of the PHP memory limit. Note - 932 in my source code is the 'throw new exception' following $xml = new SimpleXMLElement($payload); called at [/vagrant/www/maharadev/mahara/lib/errors.php:465] #1 exception(MaharaException Object ([] => 1,[] => Encrypted payload is not a valid XML document,[] => ,[] => 6002,[] => /vagrant/www/maharadev/mahara/api/xmlrpc/lib.php,[] => 932,[] => Array ([0] => Array ([file] => /vagrant/www/maharadev/mahara/api/xmlrpc/lib.php,[line] => 921,[function] => parse_payload,[args] => Array ([0] =>ERROR 4: 4: remote server error: code: , message: A nonrecoverable error occurred. This probably means you have encountered a bug in the system #0 MaharaException->handle_exception() called at [/vagrant/www/maharadev/mahara/lib/errors.php:465] #1 exception(MaharaException Object ([] => 1,[] => Encrypted payload is not a valid XML document,[] => ,[] => 6002,[] => /vagrant/www/maharadev/mahara/api/xmlrpc/lib.php,[] => 932,[] => Array ([0] => Array ([file] => /vagrant/www/maharadev/mahara/api/xmlrpc/lib.php,[line] => 921,[function] => parse_payload,[args] => Array ([0] => To manage notifications about this bug go to: https://bugs.launchpad.net/mahara/+bug/1422837/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~mahara-contributors Post to : [email protected] Unsubscribe : https://launchpad.net/~mahara-contributors More help : https://help.launchpad.net/ListHelp

