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

tool_qeupgradehelper_get_quiz_for_upgrade SQL incompatible with Postgres

    Details

    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide

      Ideally we should test this on all DBS.

      Create a Moodle 1.9 or 2.0 site with quiz attempts.

      Place 2.1, 2.2 or master code in place - but do not run upgrade yet!
      Create admin/tool/qeupgradehelper/partialupgrade.php (2.1 path is local/qeupgradehelper/partialupgrade.php), with the code:

      <?php
      function tool_qeupgradehelper_get_quizzes_to_upgrade() {
          return array();
      }

      This will cause the question attempt upgrade to not execute.

      Run the Moodle system upgrade.

      Once system upgraded, go to Question engine upgrade helper in Site Administration.
      Set cron to Yes and save.

      Execute cron.

      Before patch, on Postgres, would get a DB Execution error.

      Correct behavior (after patch), should get a series of 'upgrading quiz x' messages.

      Show
      Ideally we should test this on all DBS. Create a Moodle 1.9 or 2.0 site with quiz attempts. Place 2.1, 2.2 or master code in place - but do not run upgrade yet! Create admin/tool/qeupgradehelper/partialupgrade.php (2.1 path is local/qeupgradehelper/partialupgrade.php), with the code: <?php function tool_qeupgradehelper_get_quizzes_to_upgrade() { return array(); } This will cause the question attempt upgrade to not execute. Run the Moodle system upgrade. Once system upgraded, go to Question engine upgrade helper in Site Administration. Set cron to Yes and save. Execute cron. Before patch, on Postgres, would get a DB Execution error. Correct behavior (after patch), should get a series of 'upgrading quiz x' messages.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:

      Description

      in admin/tool/qeupgradehelper/locallib.php, function:
      tool_qeupgradehelper_get_quiz_for_upgrade

      Contains:
      SELECT quiz.id
      FROM

      {quiz_attempts}

      quiza
      JOIN

      {quiz}

      quiz ON quiz.id = quiza.quiz
      JOIN

      {course}

      c ON c.id = quiz.course
      WHERE quiza.preview = 0 AND quiza.needsupgradetonewqe = 1
      GROUP BY quiz.id, quiz.name, c.shortname, c.id
      ORDER BY quiza.timemodified DESC

      The ORDER BY clause is invalid because quiza.timemodified is not in GROUP BY or otherwise aggregated. I recommend changing it to
      ORDER BY MAX(quiza.timemodified) DESC

      but I have not verified this on other DBs yet.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12