Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-12780

Insufficient memory problem while recovering backup

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.8.3
    • None
    • Backup
    • None
    • Any environoment
    • MySQL
    • 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).

      Attachments

        Issue Links

          Activity

            People

              moodle.com Moodle HQ
              piokoch Pio Ko
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: