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

Export of questions with lots of images as Moodle XML runs out of memory

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      To test this, you need a file (Image? PDF?) that is about 40MB in size.

      1. Create a course.
      2. Go to the question bank.
      3. Create a question and add the file into the question text (either using the image or link button in Atto.)
      4. Go to Question bank -> Export.
      5. Export the default category in Moodle XML format.
      6. Verify that the export completes.
      7. Open the .xml file you downloaded, and verify that there is a large chunk of base-64 encoded data in there.
      Show
      To test this, you need a file (Image? PDF?) that is about 40MB in size. Create a course. Go to the question bank. Create a question and add the file into the question text (either using the image or link button in Atto.) Go to Question bank -> Export. Export the default category in Moodle XML format. Verify that the export completes. Open the .xml file you downloaded, and verify that there is a large chunk of base-64 encoded data in there.
    • Workaround:
      Hide

      There are now Moodle plugins to delete unused files.
      Go to the plugin directory and install these plugins.
      Use plugins:
      Moodle 2.4-2.5:

      Moodle 2.0-2.3:

      Show
      There are now Moodle plugins to delete unused files. Go to the plugin directory and install these plugins. Use plugins: Moodle 2.4-2.5: Repository "Embedded files" https://moodle.org/plugins/view.php?plugin=repository_areafiles TinyMCE plugin "Manage embedded files" https://moodle.org/plugins/view.php?plugin=tinymce_managefiles Moodle 2.0-2.3: Repository "Embedded files plus": https://moodle.org/plugins/view.php?plugin=repository_areafilesplus
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull 3.6 Branch:
    • Pull 3.7 Branch:
    • Pull Master Branch:

      Description

      We have a lot of duplicated questions with images in it and every time we try to export more as a few of these questions we get the error message "PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 14454691 bytes) in /srv/www/html/moodlep/question/format/xml/format.php on line 1135".
      We found out, that all the question files that are used in a question and all the files that ever have been used in that question are copied to the new question as well when the question is duplicated.
      When exporting that questions in the Moodle-XML-format, all that files are concatinated in a single export-string. One of these questions has the size of about 35 MB by now and with over 100 questions to export we get a string of almost 3,5 GB.
      The default moodle memory limit is 128 MB, so we increased it.
      But when we increase the memory limit to more than 2 GB we bump into a "string size limit" of 2 GB.

      Our proposition: Files, which are not part of the original question any more should not be copied to a duplicated new question.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 40 minutes
                  40m