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

Assignment submission pdf file conversions fail due to incorrect sql lookup.

XMLWordPrintable

    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_401_STABLE
    • MDL-74910-master
    • Hide

      No workarounds are available.

      Show
      No workarounds are available.
    • Easy
    • Hide

      Prerequisites

      1. A course with an assignment module
      2. Two users enrolled as students in the course from 1.

      Testing

      1. On a fresh moodle instance, install and enable the attached fileconverter plugin
        1. git clone git@github.com:catalyst/moodle-fileconverter_dummy.git files/converter/dummy
        2. Browse to "Site administration" > "Plugins" > "Document converters" > "Manage document converters" and open the eye on the "Dummy" converter - ensure all other converters are disabled
      2. As one of the students navigate to the assignment and submit a file (an image, document, it doesn't matter)
      3. As the same student, browse to private files (User drop down > Private files)
      4. Upload the same file that was submitted for the assignment
      5. From the terminal run: php admin/cli/adhoc_task.php -e
      6. Verify a row is added to the mdl_file_conversion table
      7. Wait at least 60 seconds and run php admin/cli/adhoc_task.php -e again
      8. Verify there is still only one row in mdl_file_conversion
      9. As the other student, navigate to the assignment and submit the same file as student one
      10. Run php admin/cli/adhoc_task.php -e again
      11. Verify there is still only one row in the mdl_file_conversion table
      Show
      Prerequisites A course with an assignment module Two users enrolled as students in the course from 1. Testing On a fresh moodle instance, install and enable the attached fileconverter plugin git clone git@github.com:catalyst/moodle-fileconverter_dummy.git files/converter/dummy Browse to "Site administration" > "Plugins" > "Document converters" > "Manage document converters" and open the eye on the "Dummy" converter - ensure all other converters are disabled As one of the students navigate to the assignment and submit a file (an image, document, it doesn't matter) As the same student, browse to private files (User drop down > Private files) Upload the same file that was submitted for the assignment From the terminal run: php admin/cli/adhoc_task.php -e Verify a row is added to the mdl_file_conversion table Wait at least 60 seconds and run php admin/cli/adhoc_task.php -e again Verify there is still only one row in mdl_file_conversion As the other student, navigate to the assignment and submit the same file as student one Run php admin/cli/adhoc_task.php -e again Verify there is still only one row in the mdl_file_conversion table

      There is a regression caused by changes for MDL-73727.

      The regression causes the file conversions to fail when processing the assignment submissions. This is especially noticeable when users upload documents containing multiple pages (documents with 10+ pages are almost guaranteed to break the conversion).

      The cause is one of the sub-queries inside `files/classes/conversion.php`, which returns a random row from the larger set of rows:

      ... (SELECT id
        FROM {files}
        WHERE contenthash = :ccontenthash
        LIMIT 1
      ) ...

      Without ORDER BY the sequence of rows returned by SELECT can be arbitrary. LIMIT 1 will result in picking one of them (normally 1st in the set), but because the order of rows is not enforced the first row can be random. It totally depends on the specific database instance and might not manifest itself under certain conditions creating the appearance of the normal work if the database returns the last inserted row matching conditions inside WHERE clause.

      Steps to reproduce the problem:

      1. Make sure a document converting plugin is installed and enabled. The easiest way to do so is downloading and installing the dummy file converter, which is attached to this ticket (dummy.zip).
      2. Create a test course and a test assignment with enabled "File Submissions" in Submission types. In the Feedback types the following should be set:
         [x] Feedback comments
         [x] Annotate PDF
         [x] Feedback files
      3. Enroll a student for the course.
      4. Login as the enrolled student and submit any document (.docx for instance, but bear in mind that dummy converter will use its own dummy output file for any input file).
      5. Run the conversion by calling 

      php admin/cli/scheduled_task.php --execute="\assignfeedback_editpdf\task\convert_submissions"

      from the CLI with this plugin enabled it's possible to see what a converter would be doing.

      1. Go to grading for the assignment created in step 2 with the user who has the appropriate access rights.
      1. Click "Grade" button. The preview page will display "Generating the PDF" that does not refresh or display errors.

       

      When the page in step 7 is open it keeps adding a new record in the table `mdl_file_conversion` every 2 seconds or so because of the conversion status polling. Each time the a new record is created because the program does not see the new record created on the previous iteration.

      Each new record is for the same conversion of the same file. If the page is kept open long enough it will insert thousands of rows for the same file conversion.

        1. dummy.zip
          31 kB
        2. MDL-74910_testing.mp4
          10.80 MB

            cameron1729 cameron1729
            katerynadegtyariova Kateryna Degtyariova
            Misha Golenkov Misha Golenkov
            Huong Nguyen Huong Nguyen
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            5 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 15 minutes
                3h 15m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.