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

Course Search breaks if summary is NULL

    Details

    • Database:
      PostgreSQL
    • Testing Instructions:
      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.
    • Workaround:
      Hide

      Set a summary for the course

      Show
      Set a summary for the course
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-29496-master

      Description

      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');

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    28/Nov/11