Moodle
  1. Moodle
  2. MDL-7856

Database mod search is case sensitive

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.9
    • Labels:
      None
    • Environment:
      Tested on Linux
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      27652

      Description

      In the view.php, creating the SQL statement it uses double-quotes as string delimiter. This is legal with MySQL, but far away any SQL standard sorridente and it does not work with Postgres too.
      The SQL syntax error can be seen enabling Debug.

      I'm referring to 2006080701 version of the module downloaded with Moodle 1.6.2+
      This is done in lines 308 and 321

      I fixed it changing these line as follows:

      line 308
      $searchselect = ' AND (c1.content LIKE \'%'.$search.'%\') ';

      line 321
      $searchselect = ' AND (c.content LIKE \'%'.$search.'%\') ';

      It have to be tested on MySQL, but should be compatible.

      ----------------8<---------------8<---------------8<---------------8<---------------8<----------------
      Actually, I slightly changed these lines also making the search case-insensitive.

      line 308
      $searchselect = ' AND ('.db_uppercase(). '(c1.content) LIKE \'%'.strtoupper($search).'%\') ';

      line 321
      $searchselect = ' AND ('.db_uppercase(). '(c.content) LIKE \'%'.strtoupper($search).'%\') ';

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          I have cloned the original bug to separate the case sensitive search...

          Show
          Petr Škoda added a comment - I have cloned the original bug to separate the case sensitive search...
          Hide
          Andrew Walbran added a comment -

          This is still a problem in Moodle 1.7 with PostgreSQL. I have attached a patch which shows one way of fixing this for PostgreSQL (I understand that MySQL does case-insensitive search by default).

          Show
          Andrew Walbran added a comment - This is still a problem in Moodle 1.7 with PostgreSQL. I have attached a patch which shows one way of fixing this for PostgreSQL (I understand that MySQL does case-insensitive search by default).
          Hide
          Luke Hudson added a comment -

          I have committed Andrew Walbran's patch to HEAD, as well as MOODLE_18_STABLE and MOODLE_17_STABLE

          Show
          Luke Hudson added a comment - I have committed Andrew Walbran's patch to HEAD, as well as MOODLE_18_STABLE and MOODLE_17_STABLE
          Hide
          Robert Allerstorfer added a comment -

          So this bug can be closed? The search performs case insensitive for me in Moodle 1.9+

          Show
          Robert Allerstorfer added a comment - So this bug can be closed? The search performs case insensitive for me in Moodle 1.9+
          Hide
          Petr Škoda added a comment -

          verified, case insensitive now...

          thanks for the report

          Show
          Petr Škoda added a comment - verified, case insensitive now... thanks for the report

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: