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

get_record MUST_EXIST should not throw dml_exception

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3, 3.4.3, 3.5
    • Fix Version/s: DEV backlog
    • Component/s: Database SQL/XMLDB
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide

      0. You need debugging turned on so you can see what kind of exception it is.

      1. Visit a page which uses get_record with MUST_EXIST, and pass in a parameter that isn't valid:

      http://your.server/root/group/index.php?id=999999

      2. Verify that the error message you get contains a helpful explanation such as the one above and that it isn't a dml_exception.

      Show
      0. You need debugging turned on so you can see what kind of exception it is. 1. Visit a page which uses get_record with MUST_EXIST, and pass in a parameter that isn't valid: http://your.server/root/group/index.php?id=999999 2. Verify that the error message you get contains a helpful explanation such as the one above and that it isn't a dml_exception.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Epic Link:

      Description

      When you call get_record with MUST_EXIST this currently throws a dml_exception. This should actually throw a different exception because it does not indicate a database error.

      For example the exception could be a must_exist_exception and it could contain a default language string such as:

      'Required information not found in database. This can occur if you follow an outdated or incorrect link.'

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: