Moodle
  1. Moodle
  2. MDL-34525

Incorrect pool file content when restoring a course

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: Backup
    • Labels:
    • Affected Branches:
      MOODLE_23_STABLE
    • Rank:
      42948

      Description

      When restoring a course from Moodle 1.98 into Moodle 2.31, we encountered an error on the final step which said "Incorrect pool file content". It did not have a hash or anything else after the word "content" like other issues listed in the tracker.

      After activating the debugger and playing around with it for awhile, we discovered that the issue was due to an empty <REFERENCE> element in the "moodle.xml" file in the backup. Once we removed any files that had an empty reference, we didn't incur any problems. Additionally, we resolved the issue by adding the following code:

      .../mod/resource/backup/moodle1/lib.php

      Lines: 204 - 209

      if(trim($reference) !== '') {
        try {
          $this->fileman->migrate_file('course_files/'.$reference, $curfilepath, null, 1);
        } catch (moodle1_convert_exception $e) {
          // the file probably does not exist
          $this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);
        }
      } else {
        $this->log('file reference is empty', backup::LOG_WARNING);
      }
      

      This prevents the system from trying to migrate a file to the new system if the file reference is empty.

        Activity

        Hide
        Michael de Raadt added a comment -

        Thanks for spotting that and providing a fix also.

        Show
        Michael de Raadt added a comment - Thanks for spotting that and providing a fix also.
        Hide
        Charles Fulton added a comment -

        I'm wondering if there's a deeper problem lurking in migrate_file(); a null pointer like that shouldn't get through without throwing an exception, right?

        Show
        Charles Fulton added a comment - I'm wondering if there's a deeper problem lurking in migrate_file(); a null pointer like that shouldn't get through without throwing an exception, right?
        Hide
        David Monllaó added a comment -

        Hi Blake,

        I've tried with empty REFERENCE tags, removing the file from course_files/ and doing both things at the same time, and I failed to reproduce the problem; an exception is logged but the restore always finishes as expected. Can you verify that the problem is still there or provide more info to reproduce it? Thanks in advance

        Show
        David Monllaó added a comment - Hi Blake, I've tried with empty REFERENCE tags, removing the file from course_files/ and doing both things at the same time, and I failed to reproduce the problem; an exception is logged but the restore always finishes as expected. Can you verify that the problem is still there or provide more info to reproduce it? Thanks in advance
        Hide
        David Monllaó added a comment -

        Hi,

        I see that this issue have 7 votes and it's recent, can some of you provide instructions or attach a backup file to replicate the problem? Thanks

        Show
        David Monllaó added a comment - Hi, I see that this issue have 7 votes and it's recent, can some of you provide instructions or attach a backup file to replicate the problem? Thanks
        Hide
        David Monllaó added a comment -

        I'm closing the issue as 'Cannot Reproduce'. As I commented I was unable to reproduce the problem following the reported steps; I requested additional info / examples and I emailed the issue reporter.

        I'll be watching the issue, so if someone can provide more info or a scenario to reproduce the problem we'll be glad to work on a solution.

        Show
        David Monllaó added a comment - I'm closing the issue as 'Cannot Reproduce'. As I commented I was unable to reproduce the problem following the reported steps; I requested additional info / examples and I emailed the issue reporter. I'll be watching the issue, so if someone can provide more info or a scenario to reproduce the problem we'll be glad to work on a solution.

          People

          • Votes:
            7 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: