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

backup/restore from M1.9 to M2.x does not preserve linking between resources

    Details

    • Testing Instructions:
      Hide

      Create backup:
      In Moodle 1.9 -
      In course file, create a folder, in it place two files, a image, and a html file that loads that image as a relative path (<img src="img.jpg>").
      On the front page of the course, and a Link to a file and link to the html file.
      Backup the course and download it.

      NOTE: I've attached a sample backup that is confirmed to exhibit the behavior, and also includes a 3 level deep folder test.

      In moodle 2.x
      Go into a course, go to restore, and add the 1.9 backup.
      You can restore into the existing course, merging, and use all the default settings, except on step "4. Schema" set overwrite course settings to Yes (this is because of a seeming bug that makes legacy files that may be needed by resources unavailable unless this is done).

      Complete the restore.

      Bad behavior:
      If you edit the resource created, you will notice that img.html is at the base level, instead of in a folder. If you were to upgrade the 1.9 site it would be in the subfolder.
      If you try and view the resource, the image will show as broken.

      Behavior after patch:
      The file structure is recreated in the resource, and when you view the resource, it will load in the image.

      Show
      Create backup: In Moodle 1.9 - In course file, create a folder, in it place two files, a image, and a html file that loads that image as a relative path (<img src="img.jpg>"). On the front page of the course, and a Link to a file and link to the html file. Backup the course and download it. NOTE: I've attached a sample backup that is confirmed to exhibit the behavior, and also includes a 3 level deep folder test. In moodle 2.x Go into a course, go to restore, and add the 1.9 backup. You can restore into the existing course, merging, and use all the default settings, except on step "4. Schema" set overwrite course settings to Yes (this is because of a seeming bug that makes legacy files that may be needed by resources unavailable unless this is done). Complete the restore. Bad behavior: If you edit the resource created, you will notice that img.html is at the base level, instead of in a folder. If you were to upgrade the 1.9 site it would be in the subfolder. If you try and view the resource, the image will show as broken. Behavior after patch: The file structure is recreated in the resource, and when you view the resource, it will load in the image.
    • Workaround:
      Hide

      Patch is attached.

      Show
      Patch is attached.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:

      Description

      The backup and restore of resources from Moodle 1.9.x to Moodle 2.x does not preserve linking between resources.

      I think this patch fixes this problem.

      mk

        Gliffy Diagrams

        1. bug1961_preserve_resourcelinks_backup_restore.diff
          1 kB
          Mawuli Kuivi

          Issue Links

            Activity

            Hide
            salvetore Michael de Raadt added a comment -

            Thanks for reporting that and sharing a patch.

            Could you provide a set of replication steps, just so we know the circumstances?

            Show
            salvetore Michael de Raadt added a comment - Thanks for reporting that and sharing a patch. Could you provide a set of replication steps, just so we know the circumstances?
            Hide
            t6nis20 Tõnis Tartes added a comment -

            This is just what i was looking for!

            Thank you Mawuli!!

            The same problem is addressed also in forum - http://moodle.org/mod/forum/discuss.php?d=193152

            Show
            t6nis20 Tõnis Tartes added a comment - This is just what i was looking for! Thank you Mawuli!! The same problem is addressed also in forum - http://moodle.org/mod/forum/discuss.php?d=193152
            Hide
            bazaar Mawuli Kuivi added a comment -

            Steps for replication:
            The problem was that when you have files in the 1.9 system linked inside some html resource or resource, the backup and restore to 2.x might create problems.

            If the link to the files are in the root directory of the course, then you do not have a problem.

            But if you link to some file say /dir1/dir2/filename, then this creates the problem. The restore does not create the correct link to the file. It creates to link to /filename instead of /dir1/dir2/filename.

            The /dir1/dir2/filename will correctly be restores but any resource linking to this file will end up with a problem,

            Lets create two files.

            1. /dir1/dir2/filename1
            2. /dir1/filename2

            Inside /dir1/filename2 this file, we have say
            <a href="dir2/filename1">conference</a>

            Now when you restore this to 2.x, the link inside /dir1/filename2 will now be pointing to
            <a href="filename1">conference</a> instead of <a href="dir2/filename1">conference</a>

            Hope this helps to replicate the problem.

            mk

            Show
            bazaar Mawuli Kuivi added a comment - Steps for replication: The problem was that when you have files in the 1.9 system linked inside some html resource or resource, the backup and restore to 2.x might create problems. If the link to the files are in the root directory of the course, then you do not have a problem. But if you link to some file say /dir1/dir2/filename, then this creates the problem. The restore does not create the correct link to the file. It creates to link to /filename instead of /dir1/dir2/filename. The /dir1/dir2/filename will correctly be restores but any resource linking to this file will end up with a problem, Lets create two files. 1. /dir1/dir2/filename1 2. /dir1/filename2 Inside /dir1/filename2 this file, we have say <a href="dir2/filename1">conference</a> Now when you restore this to 2.x, the link inside /dir1/filename2 will now be pointing to <a href="filename1">conference</a> instead of <a href="dir2/filename1">conference</a> Hope this helps to replicate the problem. mk
            Hide
            emerrill Eric Merrill added a comment -

            We have also been seeing this problem.

            I've added testing instructions, pull branches for 2.1, 2.2 and master (thanks for the patch Mawuli!), and a 1.9 backup file to help with testing.

            Show
            emerrill Eric Merrill added a comment - We have also been seeing this problem. I've added testing instructions, pull branches for 2.1, 2.2 and master (thanks for the patch Mawuli!), and a 1.9 backup file to help with testing.
            Hide
            emerrill Eric Merrill added a comment -

            Oh, I also tested the patch and a few test cases and it seems to work as it should.

            Show
            emerrill Eric Merrill added a comment - Oh, I also tested the patch and a few test cases and it seems to work as it should.
            Hide
            salvetore Michael de Raadt added a comment -

            Thanks for adding more information.

            I'll see if we can get this peer reviewed soon.

            Show
            salvetore Michael de Raadt added a comment - Thanks for adding more information. I'll see if we can get this peer reviewed soon.
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks everyone for your work on this - it looks good to me, submitting for integration!

            Show
            poltawski Dan Poltawski added a comment - Thanks everyone for your work on this - it looks good to me, submitting for integration!
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            Hide
            emerrill Eric Merrill added a comment -

            Rebased.

            Show
            emerrill Eric Merrill added a comment - Rebased.
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks guys this has been integrated now.
            Please note I did make an extra commit to fix whitespace however.

            Cheers
            Sam

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks guys this has been integrated now. Please note I did make an extra commit to fix whitespace however. Cheers Sam
            Hide
            rwijaya Rossiani Wijaya added a comment -

            This looks great.

            Test passed.

            Show
            rwijaya Rossiani Wijaya added a comment - This looks great. Test passed.
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            UPDATE tracker_issues
               SET status = 'Closed',
                  comment = 'Thanks!'
            WHEN participants = 'Did a gorgeous work'

            This landed upstream some hours ago (some - me - developer fell slept in the sofa yesterday before spamming this).

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - UPDATE tracker_issues SET status = 'Closed', comment = 'Thanks!' WHEN participants = 'Did a gorgeous work' This landed upstream some hours ago (some - me - developer fell slept in the sofa yesterday before spamming this).

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12