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

grade_get_grade_items_for_activity gets error reading from database where modname is not set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.9, 2.5.5, 2.6.2, STABLE backlog
    • Fix Version/s: 2.5.7, 2.6.4, 2.7.1
    • Component/s: Enrolments
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide
      • Run the unit test:
        vendor/bin/phpunit grade/tests/querylib_test.php
      • Make sure it pass, and you don't receive this message:

        1) core_grade_querylib_testcase::test_grade_get_grade_items_for_activity
        dml_read_exception: Error reading from database (You have an error in your SQL syntax; 
        check the manual that corresponds to your MySQL server version for the right syntax to 
        use near 'WHERE cm.id = '1' AND md.id = cm.module' at line 4
        SELECT cm.*, m.name, md.name as modname
                                            FROM phpu_course_modules cm,
                                                 phpu_modules md,
                                           WHERE cm.id = ? AND md.id = cm.module
        [array (
          0 => '1',
        )])
        

      Show
      Run the unit test: vendor/bin/phpunit grade/tests/querylib_test.php Make sure it pass, and you don't receive this message: 1) core_grade_querylib_testcase::test_grade_get_grade_items_for_activity dml_read_exception: Error reading from database (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE cm.id = '1' AND md.id = cm.module' at line 4 SELECT cm.*, m.name, md.name as modname FROM phpu_course_modules cm, phpu_modules md, WHERE cm.id = ? AND md.id = cm.module [array ( 0 => '1', )])
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-45323-master

      Description

      In grade/querylib.php function grade_get_grade_items_for_activity

      When it is called with $cm without modname it gets error reading from database where modname is not set.

      This is caused by the malformed SQL on line 257.

      Patch https://github.com/moodle/moodle/pull/90/files

      The same patch can be applied in all affected versions

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Jul/14