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

SUBSTR function in accesslib.php fails on MS SQL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.1, 1.9.2
    • Fix Version/s: 1.9.3
    • Component/s: Course
    • Labels:
      None
    • Environment:
      Microsoft SQL
    • Database:
      Microsoft SQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      lib/accesslib.php makes a call to SQL function SUBSTR in the statement:
      $sql = "UPDATE {$CFG->prefix}context
      SET path = ".sql_concat("'$newpath'", 'SUBSTR(path, '.$len.' +1)')."
      $setdepth
      WHERE path LIKE '{$frompath}/%'";
      execute_sql($sql,false);

      but SUBSTR is not legitimate in MSSQL, SUBSTRING must be used, which is fine with MySQL except there may be a difference in the length parameter.

      Problem discussed at:
      http://moodle.org/mod/forum/discuss.php?d=106337

        Attachments

          Activity

            People

            • Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              jwhite10 John White
              Tester:
              Petr Skoda
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, 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:
                15/Oct/08