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

Course Search breaks if summary is NULL

XMLWordPrintable

    • PostgreSQL
    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE
    • wip-MDL-29496-master
    • Hide

      Set a summary for the course

      Show
      Set a summary for the course
    • Hide

      1) Create a new course using either the LDAP, or database auth mechanisms - these use create_course() without the second (optional) argument - alternatively, update an existing course to set the summary to NULL.
      2) Try and search for that course.
      3) Run the DB functional tests under all DBs. Verify now failure related to test_coalesce() happens.

      Show
      1) Create a new course using either the LDAP, or database auth mechanisms - these use create_course() without the second (optional) argument - alternatively, update an existing course to set the summary to NULL. 2) Try and search for that course. 3) Run the DB functional tests under all DBs. Verify now failure related to test_coalesce() happens.

      If courses have been created by an enrolment plugin which doesn't provide any summary, then the summary field is set to null.

      Under Postgres (and probably other DBs) when the fullname and summary are concatenated, the presence of the NULL summary field means that the resulting concatenation is also null.

      E.g.:
      If summary = 'foo', and fullname = 'bar', then summary || ' ' || fullname = 'foo bar'
      If summary IS NULL, and fullname = 'bar', then summary || ' ' || fulname = NULL

      As a result, the search fails to match on valid fullname matches.

      I'm unsure as to how compatible COALESCE is, but under Postgres, COALESCEing the summary, and an empty string ensures that we can search if the summary is NULL.
      For example:

        $concat = $DB->sql_concat('c.summary', "' '", 'c.fullname', "' '", 'c.idnumber', "' '", 'c.shortname');

      becomes:

        $concat = $DB->sql_concat("COALESCE(c.summary, '')", "' '", 'c.fullname', "' '", 'c.idnumber', "' '", 'c.shortname');

            phalacee Jason Fowler
            dobedobedoh Andrew Lyons
            Ankit Agarwal Ankit Agarwal
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Sam Hemelryk Sam Hemelryk
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.