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

Restore failing because xml_parse() crashes

    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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  21/Oct/09