Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.9.3
-
Fix Version/s: 1.9.6
-
Component/s: Backup
-
Labels:None
-
Environment:Moodle 1.9.3+ (Build: 20081029), MySql 5.0.51a-24-log, debian, apache2, and php5
-
Database:MySQL
-
Affected Branches:MOODLE_19_STABLE
-
Fixed Branches:MOODLE_19_STABLE
Description
After a lot of time and a lot of error_log('pliska X') debug lines... I found out that it is the xml_parse() function that is crashing; possibly because of a charset problem.
when you restore a course, you hit /backup/restore.php
/backup.restore.php calls the restore_execute function
restore_execute calls restore_create_groupings_groups
restore_create_groupings_groups calls restore_read_xml_groupings_groups
restore_read_xml_groupings_groups calls restore_read_xml
restore_read_xml calls xml_parse
CRASH
restore_read_xml is located at /backup/restorelib.php . This is the one that calls xml_parse and I know that it crashed because I modified the code a little bit and got to some conclusions. First check out the mods I made on restore_read_xml:
------------------------
while ($data = fread($fp, 4096) and !$moodle_parser->finished) {
error_log ('pliska 140');
if ((time() - $lasttime) > 5) {
$lasttime = time();
backup_flush(1);
}
error_log ('pliska 141|' . $data . '|' . feof($fp) . '|' . xml_get_current_line_number($xml_parser));
$parse_ok = xml_parse($xml_parser, $data, feof($fp));
error_log ('pliska 142|');
//or die(sprintf("XML error: %s at line %d",
//xml_error_string(xml_get_error_code($xml_parser)),
// xml_get_current_line_number($xml_parser)));
//or die(error_log ('pliska 160|' . xml_error_string(xml_get_error_code($xml_parser)) . '|' . xml_get_current_line_number($xml_parser)));
error_log ('pliska 159|' . $parse_ok);
if (!$parse_ok) {
error_log ('pliska 160|' . xml_error_string(xml_get_error_code($xml_parser)) . '|' . xml_get_current_line_number($xml_parser));
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
------------------------
On the last lines of the apache error log I see "pliska 141" and I do not see "pliska 142". The output of the last pliska 141 is the following:
pliska 141|DATA||15234, referer: https://our-site.url/backup/restore.php
I attached DATA to this post in the DATA.xml file.
the DATA looks pretty clean to my eyes, what could be making the restore crash?
I have been able to reproduce this error on 3 installations of Moodle 1.9.3 . By restoring the attached backup file.
Hi Pedro,
thanks for your complete report!
Unluckily, I've been able to restore the attached course without problems at all
Apparently the XML is well-formed and I cannot imagine any problem but:
1) Some bug in old Moodle 1.9.3 (I'd recommend to try it with latest 1.9.x+ weekly available).
2) Some bug in the underlying XML libs (from OS). It has been some reports in the past about some buggy libxml libraries in the OS causing problems with intensive parsing like the performed by restore.
Also, were you running Moodle with debug raised to its maximum level (DEBUG_DEVELOPER) in admin->server->debug? If not, please, try again with that level enabled. Just to see if you get some error giving us some tip.
I'm going to resolve this as Cannot reproduce now. Feel free to reopen if you are able to find anything else related with this bug.
TIA and ciao