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

Assignment pdf conversion doesn't clean up after failure

    Details

    • Testing Instructions:
      Hide

      TEST 1

      1. # Edit mod/assign/feedback/editpdf/classes/document_services.php - throw an exception between the $convertedfile = $fs->get_converted_document line and the $htmlfile->delete line to simulate a failure (in the try block)
      2. Add an assignment to a course (with both online text and file submission types enabled)
      3. Log in as a student
      4. Make a plain text submission for the assignment
      5. Log back in as the teacher
      6. Navigated to the assigment and grade the student's submission
      7. You should get a failure due to the exception added earlier
      8. Remove the line throwing the exception from step 1
      9. Attempt to grade the submission again
      10. You should not get errors about duplicate files

      TEST 2

      1. This test needs to be done before applying the above patch and upgrading.
      2. Make a few submissions as before.
      3. Add the exception at the same place.
      4. Try to grade those submissions and make sure you see the errors.
      5. Goto database and check mdl_files table , make sure there are some entries with filename "onlinetext-" and editpdf componenent
      6. Remove exception, apply patch, upgrade.
      7. Check database again, those files should be deleted now.
      8. Try to grade those assignments, there should not be any error.
      Show
      TEST 1 # Edit mod/assign/feedback/editpdf/classes/document_services.php - throw an exception between the $convertedfile = $fs->get_converted_document line and the $htmlfile->delete line to simulate a failure (in the try block) Add an assignment to a course (with both online text and file submission types enabled) Log in as a student Make a plain text submission for the assignment Log back in as the teacher Navigated to the assigment and grade the student's submission You should get a failure due to the exception added earlier Remove the line throwing the exception from step 1 Attempt to grade the submission again You should not get errors about duplicate files TEST 2 This test needs to be done before applying the above patch and upgrading. Make a few submissions as before. Add the exception at the same place. Try to grade those submissions and make sure you see the errors. Goto database and check mdl_files table , make sure there are some entries with filename "onlinetext-" and editpdf componenent Remove exception, apply patch, upgrade. Check database again, those files should be deleted now. Try to grade those assignments, there should not be any error.
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull 3.1 Branch:
    • Pull Master Branch:
      MDL-55859-master
    • Sprint:
      3.3 sprint 4

      Description

      Reproduction steps:

      1. Edit mod/assign/feedback/editpdf/classes/document_services.php - throw an exception between the $convertedfile = $fs->get_converted_document line and the $htmlfile->delete line to simulate a failure
      2. Add an assignment to a course (with both online text and file submission types enabled)
      3. Log in as a student
      4. Make a plain text submission for the assignment
      5. Log back in as the teacher
      6. Navigated to the assigment and grade the student's submission
      7. You should get a failure due to the exception added earlier
      8. Remove the line throwing the exception from step 1
      9. Attempt to grade the submission again
      10. You should get errors about duplicate files and won't be able to give feedback

      Original report

      Assignment allows file upload and online text. When Teacher clicks Grade button in Assignment, the receive following error:

      Can not create file "1305/assignfeedback_editpdf/importhtml/307/onlinetext-onlinetext.html"
      File:
      ...age/file_storage.php

      Line: 1590

      Stack trace:

      Duplicate entry 'c673447ed6162145a7b373k8e8428a6b27c13579' for key 'mdl_file_pat_uix'INSERT INTO mdl_files (contextid,component,filearea,itemid,filepath,filename,timecreated,timemodified,userid,source,author,license,status,sortorder,filesize,contenthash,mimetype,pathnamehash) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)[array ( 0 => 1305, 1 => 'assignfeedback_editpdf', 2 => 'importhtml', 3 => '307', 4 => '/', 5 => 'onlinetext-onlinetext.html', 6 => 1472558696, 7 => 1472558696, 8 => NULL, 9 => NULL, 10 => NULL, 11 => NULL, 12 => 0, 13 => 0, 14 => 78, 15 => 'c202da428649a754c4f6dd5c8d9928813bcb41ca', 16 => 'text/html', 17 => 'c673447ed6162145a7b3779de84ss26b27c13579',)]Error code: storedfilenotcreated

      The session for the user usually stalls forcing a clearing of browser cache/cookies to re enter site.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  13 Vote for this issue
                  Watchers:
                  33 Start watching this issue

                  Dates

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