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

PostgreSQL error: Empty string instead of integer in the query

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.5
    • Fix Version/s: 1.8.5, 1.9, 2.0
    • Component/s: Feedback
    • Labels:
      None
    • Environment:
      Spotted at MOODLE_18_STABLE checked out from CONTRIB
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      PostgreSQL does not like queries with
      ... WHERE id = ''

      The following code in mod_form.php (around line# 61) throws error:

      if ($feedback = get_record("feedback", "id", $this->_instance)) {
      $completedFeedbackCount = feedback_get_completeds_group_count($feedback);
      } else {
      $completedFeedbackCount = false;
      }

      My proposal is to use:

      if (is_numeric($this->_instance) && ($feedback = get_record("feedback", "id", $this->_instance))) {
      $completedFeedbackCount = feedback_get_completeds_group_count($feedback);
      } else {
      $completedFeedbackCount = false;
      }

        Attachments

          Activity

            People

            • Assignee:
              grabs Andreas Grabs
              Reporter:
              mudrd8mz David Mudrák (@mudrd8mz)
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08