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

download_file_content fails under certain conditions

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide
      1. Go to SCORM package settings (Site administration ► Plugins ► Activity modules ► SCORM package), and enable "downloaded package type" (scorm | allowtypelocalsync)
      2. Verify you have the default value of 56 set for "curltimeoutkbitrate" in Performance settings (Site administration ► Server ► Performance).
      3. Create a new SCORM module, choosing "Downloaded package" as the Type and entering a remote URL for downloading from
      4. Enter the following URL – http://www.ostyn.com/standards/scorm/samples/proddingsco.zip
      5. Save
      Show
      Go to SCORM package settings ( Site administration ► Plugins ► Activity modules ► SCORM package ), and enable "downloaded package type" (scorm | allowtypelocalsync) Verify you have the default value of 56 set for "curltimeoutkbitrate" in Performance settings ( Site administration ► Server ► Performance ). Create a new SCORM module, choosing "Downloaded package" as the Type and entering a remote URL for downloading from Enter the following URL – http://www.ostyn.com/standards/scorm/samples/proddingsco.zip Save
    • Workaround:
      Hide

      Set the global config setting curltimeoutkbitrate to zero and the SCORM will be created successfully.

      Show
      Set the global config setting curltimeoutkbitrate to zero and the SCORM will be created successfully.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-38268-master

      Description

      Steps to reproduce::
      1) Go to SCORM package settings, and enable "downloaded package type" (scorm | allowtypelocalsync)
      2) Verify you have the default value of 56 set for "curltimeoutkbitrate" in Settings.
      3) Create a new SCORM module, choosing "Downloaded package" as the Type and entering a remote URL for downloading from
      4) Save

      Now you can set curltimeoutkbitrate to zero and the SCORM will be created successfully. I'm attaching my screenshot. I believe Heather was receiving a slightly different error, but having a similar outcome.

      The problem seems to be in lib/filelib.php around line 1230:

             curl_setopt_array ($ch, array(
                  CURLOPT_RETURNTRANSFER => true,
                  CURLOPT_NOBODY         => false)
              );
      

      The problem here is that simply setting CURLOPT_NOBODY to false is insufficient.

      From the PHP documentation:
      CURLOPT_NOBODY - TRUE to exclude the body from the output. Request method is then set to HEAD. Changing this to FALSE does not change it to GET.

      CURLOPT_HTTPGET - TRUE to reset the HTTP request method to GET. Since GET is the default, this is only necessary if the request method has been changed.

      Changing as such allowed the file to successfully download if the curltimeoutkbitrate value was set:

              curl_setopt_array ($ch, array(
                  CURLOPT_RETURNTRANSFER => true,
                  CURLOPT_NOBODY         => false,
                  CURLOPT_HTTPGET        => true)
              );
      

      It may be worthwhile to check for this in other areas of Moodle also?

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Mar/13