Moodle
  1. Moodle
  2. MDL-31396

Trying to export a preset as a .zip file results in errors

    Details

    • Testing Instructions:
      Hide

      1) Add a database module
      2) Create some fields and add one or two records.
      3) Click on the Templates tab and click Save Template at the bottom of the page. (No need to alter the template)
      4) Click on the Presets tab. Click Export under the 'Export as zip' section.
      [Test] Check to see if a dialogue box pops up asking you to save the file.
      5) Save the file.
      6) Create a new database activity.
      7) Click on the Presets tab. in the 'Import from zip file' section choose the downloaded file and then import.
      [Test] Make sure that the fields are still the same as the previous database module.

      Show
      1) Add a database module 2) Create some fields and add one or two records. 3) Click on the Templates tab and click Save Template at the bottom of the page. (No need to alter the template) 4) Click on the Presets tab. Click Export under the 'Export as zip' section. [Test] Check to see if a dialogue box pops up asking you to save the file. 5) Save the file. 6) Create a new database activity. 7) Click on the Presets tab. in the 'Import from zip file' section choose the downloaded file and then import. [Test] Make sure that the fields are still the same as the previous database module.
    • Workaround:
      Hide

      I had a look at a difference between the code from 2.1 and master. It appears that make_upload_directory() has been switched for make_temp_directory(). Changing it back solves the problem, but I'm sure that there is probably some reason that I'm not aware of that this line of code has been changed.

      line 3145 of /mod/data/lib.php

      $exportsubdir = "temp/mod_data/presetexport/$presetname";
      make_upload_directory($exportsubdir);
      
      Show
      I had a look at a difference between the code from 2.1 and master. It appears that make_upload_directory() has been switched for make_temp_directory(). Changing it back solves the problem, but I'm sure that there is probably some reason that I'm not aware of that this line of code has been changed. line 3145 of /mod/data/lib.php $exportsubdir = "temp/mod_data/presetexport/$presetname" ; make_upload_directory($exportsubdir);
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-31396-master
    • Rank:
      37913

      Description

      When trying to export a preset in the database module as a zip file it doesn't create a file but instead displays an error "Not all files generated!"
      I've included a screen shot with the various warnings and stack trace.

        Issue Links

          Activity

          Hide
          Andrew Davis added a comment -

          Your code change looks fair enough although it probably shouldnt go in until we've established why it was changed in the first place. Does git blame or some tracker searching turn anything up? If its been modified since 2.1 thats reasonably recent.

          Show
          Andrew Davis added a comment - Your code change looks fair enough although it probably shouldnt go in until we've established why it was changed in the first place. Does git blame or some tracker searching turn anything up? If its been modified since 2.1 thats reasonably recent.
          Hide
          Adrian Greeve added a comment -

          Thanks for the peer review Andrew. I did a bit more digging and found that this problem is a regression from MDL-28701. I'll have to think of a different way to fix this problem.

          Show
          Adrian Greeve added a comment - Thanks for the peer review Andrew. I did a bit more digging and found that this problem is a regression from MDL-28701 . I'll have to think of a different way to fix this problem.
          Hide
          Adrian Greeve added a comment -

          I found out that the export directory was looking in a different place to where the directory that was being created by make_temp_directory().
          This has now been fixed. Re-submitting for peer review.

          Show
          Adrian Greeve added a comment - I found out that the export directory was looking in a different place to where the directory that was being created by make_temp_directory(). This has now been fixed. Re-submitting for peer review.
          Hide
          Andrew Davis added a comment -

          Cool. Code looks good. Just needs some testing instructions and its all set.

          Show
          Andrew Davis added a comment - Cool. Code looks good. Just needs some testing instructions and its all set.
          Hide
          Sam Hemelryk added a comment -

          Thanks Adrian this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Adrian this has been integrated now
          Hide
          Rossiani Wijaya added a comment -

          This is working great.

          Test passed.

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

          It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks!

          Closing as fixed, heading to zzzZZZzzz, niao

          Show
          Eloy Lafuente (stronk7) added a comment - It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks! Closing as fixed, heading to zzzZZZzzz, niao

            People

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

              Dates

              • Created:
                Updated:
                Resolved: