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

Assignment conversion query fails in Amazon Aurora postgres 16.1+

    • MOODLE_401_STABLE, MOODLE_403_STABLE
    • MDL-81863-fix-conversion-query-postgresql-MOODLE_401_STABLE
    • MDL-81863-fix-conversion-query-postgresql-MOODLE_403_STABLE
    • MDL-81863-fix-conversion-query-postgresql
    • Hide

      There are a couple of ways to test the code:

      1. Log in to Moodle as an admin user.

      2. Verify Ghostscript Path : https://siteurl.com/mod/assign/feedback/editpdf/testgs.php

      3. Create Test Course: https://siteurl.com/admin/tool/generator/maketestcourse.php

      4. Configure Assignment

      • Open the test course.
      • Open an assignment.
      • Set Submission types to File submissions.
      • Enable Annotate PDF under Feedback types.

      5. Check Adhoc Task: https://siteurl.com/admin/tool/task/adhoctasks.php?classname=%5Cassignfeedback_editpdf%5Ctask%5Cconvert_submission

      • Initially, you'll see an empty adhoc listing page.

      6. Submit Assignment as Student

      • Open a private window or another browser.
      • Log in as a student.
      • Submit a document for the assignment.

      7. Run Adhoc Task

      • Return to the admin user tab with the adhoc task page opened in step 5
      • You should now see the adhoc task listed
      • Click Run now to execute the adhoc task

      Confirm that the adhoc task runs without the ERROR: could not determine data type of parameter $3 and completes with the message The document has been successfully converted.

      Alternatively: Using PHPUnit Tests

      1. Navigate to your Moodle directory:

      cd /home/example/moodle

      2. Initialise the test environment:

      php admin/tool/phpunit/cli/init.php
      

      3. Run a single PHPUnit test file

      vendor/bin/phpunit mod/assign/feedback/editpdf/tests/feedback_test.php
      

      Confirm that the unit test completes successfully without any errors like:

      Error reading from database Debug: ERROR: could not determine data type of parameter $3
      Error code: dmlreadexception
      

      Show
      There are a couple of ways to test the code: 1. Log in to Moodle as an admin user. 2. Verify Ghostscript Path : https://siteurl.com/mod/assign/feedback/editpdf/testgs.php If not working, install Ghostscript and set the path: https://siteurl.com/admin/settings.php?section=systempaths 3. Create Test Course: https://siteurl.com/admin/tool/generator/maketestcourse.php 4. Configure Assignment Open the test course. Open an assignment. Set Submission types to File submissions . Enable Annotate PDF under Feedback types . 5. Check Adhoc Task: https://siteurl.com/admin/tool/task/adhoctasks.php?classname=%5Cassignfeedback_editpdf%5Ctask%5Cconvert_submission Initially, you'll see an empty adhoc listing page. 6. Submit Assignment as Student Open a private window or another browser. Log in as a student. Submit a document for the assignment. 7. Run Adhoc Task Return to the admin user tab with the adhoc task page opened in step 5 You should now see the adhoc task listed Click Run now to execute the adhoc task Confirm that the adhoc task runs without the ERROR: could not determine data type of parameter $3 and completes with the message The document has been successfully converted . Alternatively: Using PHPUnit Tests 1. Navigate to your Moodle directory: cd /home/example/moodle 2. Initialise the test environment: php admin/tool/phpunit/cli/init.php 3. Run a single PHPUnit test file vendor/bin/phpunit mod/assign/feedback/editpdf/tests/feedback_test.php Confirm that the unit test completes successfully without any errors like: Error reading from database Debug: ERROR: could not determine data type of parameter $3 Error code: dmlreadexception
    • Hide

      Fails against automated checks.

      Checked MDL-81863 using repository: https://github.com/rajandangi/moodle

      Should these errors be fixed?

      Built on: Wed Apr 30 14:16:08 UTC 2025

      Show
      Fails against automated checks. Checked MDL-81863 using repository: https://github.com/rajandangi/moodle MOODLE_401_STABLE [branch: MDL-81863-fix-conversion-query-postgresql-MOODLE_401_STABLE | CI Job ] Error: The MDL-81863 -fix-conversion-query-postgresql-MOODLE_401_STABLE branch at https://github.com/rajandangi/moodle is very old (>60 days ago). Please rebase against current MOODLE_401_STABLE. MOODLE_403_STABLE [branch: MDL-81863-fix-conversion-query-postgresql-MOODLE_403_STABLE | CI Job ] Error: The MDL-81863 -fix-conversion-query-postgresql-MOODLE_403_STABLE branch at https://github.com/rajandangi/moodle is very old (>60 days ago). Please rebase against current MOODLE_403_STABLE. main [branch: MDL-81863-fix-conversion-query-postgresql | CI Job ] Error: The MDL-81863 -fix-conversion-query-postgresql branch at https://github.com/rajandangi/moodle is very old (>60 days ago). Please rebase against current main. Should these errors be fixed? Built on: Wed Apr 30 14:16:08 UTC 2025

      I just wanted to create an issue to document the case somewhere. Moodle sites where it was happening were patched but maybe it will become a bigger problem for somebody else in the future.

      This was reproduced under:

      • PHP 7.4, Moodle 3.11, postgresql 16.1 (Amazon Aurora)
      • PHP 8.1.28 Moodle 4.3.4 , postgresql 16.1 (Amazon Aurora)
      • PHP 8.1.28 Moodle 4.3.4 , postgresql 16.2 (Amazon Aurora)

      I believe PHP and Moodle versions are not important. However it is not failing in normal Postgresql 16.1. This query is also covered by unittests (so I guess it does not happen in any of our testing matrices).

      Default exception handler: Error reading from database Debug: ERROR:  could not determine data type of parameter $3
       
       
      SELECT c.id AS conversionid, c.sourcefileid AS conversionsourcefileid, c.targetformat AS conversiontargetformat, c.status AS conversionstatus, c.statusmessage AS conversionstatusmessage, c.converter AS conversionconverter, c.destfileid AS conversiondestfileid, c.data AS conversiondata, c.timecreated AS conversiontimecreated, c.timemodified AS conversiontimemodified, c.usermodified AS conversionusermodified
                      FROM mdl_file_conversion c
                      INNER JOIN mdl_files conversionsourcefile ON conversionsourcefile.id = c.sourcefileid
                      LEFT JOIN mdl_files conversiondestfile ON conversiondestfile.id = c.destfileid
                      WHERE
                          conversionsourcefile.contenthash = $1
                      AND c.targetformat = $2
                      AND (
                          c.destfileid IS NULL OR conversiondestfile.id IS NOT NULL
                      )
                  UNION ALL
                      SELECT
                          NULL AS conversionid,
                          orphanedsourcefile.id AS conversionsourcefileid,
                          $3 AS conversiontargetformat,
                          2 AS conversionstatus,
                          NULL AS conversionstatusmessage,
                          NULL AS conversionconverter,
                          orphaneddestfile.id AS conversiondestfileid,
                          NULL AS conversiondata,
                          0 AS conversiontimecreated,
                          0 AS conversiontimemodified,
                          0 AS conversionusermodified
                      FROM mdl_files orphanedsourcefile
                      INNER JOIN mdl_files orphaneddestfile ON (
                              orphaneddestfile.filename = orphanedsourcefile.contenthash
                          AND orphaneddestfile.component = 'core'
                          AND orphaneddestfile.filearea = 'documentconversion'
                          AND orphaneddestfile.filepath = $4
                      )
                      LEFT JOIN mdl_file_conversion orphanedconversion ON orphanedconversion.destfileid = orphaneddestfile.id
                      WHERE
                          orphanedconversion.id IS NULL
                      AND
                          orphanedsourcefile.id = $5
                      
      [array (
        0 => '8b57065a9d5ceccbef6de4eb4cb9f02c2b4cf3d0',
        1 => 'pdf',
        2 => 'pdf',
        3 => '/pdf/',
        4 => '15743766',
      )]
      Error code: dmlreadexception
      * line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
      * line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
      * line 338 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_slave_query_end()
      * line 986 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 179 of /files/classes/conversion.php: call to pgsql_native_moodle_database->get_records_sql()
      * line 75 of /files/classes/converter.php: call to core_files\\conversion::get_conversions_for_file()
      * line 215 of /mod/assign/feedback/editpdf/classes/document_services.php: call to core_files\\converter->start_conversion()
      * line 319 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assignfeedback_editpdf\\document_services::list_compatible_submission_files_for_attempt()
      * line 95 of /mod/assign/feedback/editpdf/ajax.php: call to assignfeedback_editpdf\\document_services::get_combined_document_for_attempt()
      , referer https://..../mod/assign/view.php?id=766564&action=grader&userid=23608
      

            Unassigned Unassigned
            marina Marina Glancy
            Votes:
            6 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:

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