Moodle

Insufficien memory problem while recovering backup

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.8.3
  • Fix Version/s: None
  • Component/s: Backup
  • Labels:
    None
  • Environment:
    Any environoment
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE

Description

The problem lies in the approach to the backup recovery. XML file containing backup data is loaded to the array and then processed. This does not scale well when we have a large course - the array becomes very large. In addition XML parsing is left to the lib/xmlize.php, which has the following shortcomming
1. Misleading and useless documentation - the documentation says that function xmlize() "Create xml formatted output from an array" which is not true, since this function creates array from the xml file.
2. In xmlize() there is a following code:

$vals = $index = $array = array();
$parser = xml_parser_create($encoding);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $WHITE);
xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);

which creates never used $index array. As a result, even more data are stored in memory.

I suggest to:
1. fix the comment
2. change above code to:

$data = trim($data);
$vals = $array = array();
$parser = xml_parser_create($encoding);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $WHITE);
xml_parse_into_struct($parser, $data, $vals);
xml_parser_free($parser);

3. in some future realese change the approach to backup recovery - there is no use to recreate whole XML tree as an array (even if such an approach is requiered it is better to use XML DOM interface).

Issue Links

Activity

There are no comments yet on this issue.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: