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

DB Upgrade script contains hard coded database prefix.

    Details

      Description

      MDL-38173 Introduced update code in '/lib/db/upgrade.php' which contains a hard coded database prefix:

              $sql = 'SELECT s2.id, s2.course, s2.sequence
                      FROM mdl_course_sections s2
                      JOIN(
                          SELECT DISTINCT s.id
                          FROM
                          {course_modules} cm
                          JOIN {course_sections} s
                          ON
                              cm.course = s.course
                          WHERE cm.section != s.id AND ' . $sequenceconcat . ' LIKE ' . $moduleconcat . '
                      ) d
                      ON s2.id = d.id';
              $coursesections = $DB->get_recordset_sql($sql);
      

      This means that if the database prefix is not 'mdl_' then an error occurs and the upgrade fails:

      Debug info: Table 'moodlegjb.mdl_course_sections' doesn't exist
      SELECT s2.id, s2.course, s2.sequence 
      FROM mdl_course_sections s2 
      JOIN( 
      SELECT DISTINCT s.id 
      FROM 
      mdl23_course_modules cm 
      JOIN mdl23_course_sections s 
      ON 
      cm.course = s.course 
      WHERE cm.section != s.id AND CONCAT(',', s.sequence, ',') LIKE CONCAT('%,', cm.id, ',%') 
      ) d 
      ON s2.id = d.id
      [array (
      )] 
      Error code: dmlreadexception
      Stack trace:
      line 407 of \lib\dml\moodle_database.php: dml_read_exception thrown
      line 903 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1091 of \lib\db\upgrade.php: call to mysqli_native_moodle_database->get_recordset_sql()
      line 1480 of \lib\upgradelib.php: call to xmldb_main_upgrade()
      line 275 of \admin\index.php: call to upgrade_core()
      

      The workaround is to manually edit 'upgrade.php' and change the prefix.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    11/Mar/13