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

Database preset import doesn't work on Windows

    Details

    • Testing Instructions:
      Hide

      Test pre-requisites

      • A windows server to test this on.

      Test steps

      1. Log in as admin/teacher.
      2. Navigate to a course.
      3. Create a Database activity.
      4. Click on the Preset tab.
      5. Upload a preset zip file.
      6. Work through the import process.
        • The import should succeed with no errors.
      • Test again with Ubuntu or some other operating system to ensure there are no regressions.
      Show
      Test pre-requisites A windows server to test this on. Test steps Log in as admin/teacher. Navigate to a course. Create a Database activity. Click on the Preset tab. Upload a preset zip file. Work through the import process. The import should succeed with no errors. Test again with Ubuntu or some other operating system to ensure there are no regressions.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-36453-master

      Description

      When trying to import a Database activity preset file on a Windows server, the import fails as the importer filters away part of the imported file's filename part way through.

      To replicate this, you will need a server on Windows.

      Replication steps:

      1. Log in as admin/teacher
      2. Navigate to a course
      3. Create a Database activity
      4. Click on the Preset tab
      5. Upload a preset zip file (I will attach an example)
      6. Work through the import process

      Expected result: The import should complete successfully

      Actual result: The import fails in the final stage and reports a 'cannotimport' error (with little detail).

      On a Windows server, the preset file is passed to the server with a .tmp extension (eg. tem2464.tmp). This is able to be extracted to a directory (eg. tem2464.tmp_extracted) without trouble, but on line 219, the extracted preset directory is received as a form field and the PARAM_ALPHANUMEXT filter is applied, which removes dots (eg. tem2464tmp_extracted). When the script checks that the directory exists, this fails and the import fails.

      $presetdir = $CFG->tempdir.'/forms/'.required_param('directory', PARAM_ALPHANUMEXT);

      Replacing this filter with the more appropriate PARAM_FILE filter allows dots through and allows the preset import to complete.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jan/13