Issue Details (XML | Word | Printable)

Key: MDL-12780
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Martin Dougiamas
Reporter: Pio Ko
Votes: 1
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Insufficien memory problem while recovering backup

Created: 31/Dec/07 08:16 PM   Updated: 09/Apr/08 06:46 AM
Return to search
Component/s: Backup
Affects Version/s: 1.8.3
Fix Version/s: None

Environment: Any environoment
Issue Links:
Dependency
 

Database: MySQL
Participants: Martin Dougiamas and Pio Ko
Security Level: None
Affected Branches: MOODLE_18_STABLE


 Description  « Hide
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).


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.