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

PostgreSQL error: Empty string instead of integer in the query

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.5
    • 1.8.5, 1.9, 2.0
    • Feedback
    • None
    • Spotted at MOODLE_18_STABLE checked out from CONTRIB
    • PostgreSQL
    • MOODLE_18_STABLE
    • 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

            grabs Andreas Grabs
            mudrd8mz David Mudrák (@mudrd8mz)
            Amaia Anabitarte, Carlos Escobedo, Laurent David, Mikel Martín Corrales, Sabina Abellan, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3/Mar/08