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

Error Writing to Database During Course Reset After Upgrade to 2.x

XMLWordPrintable

    • Any
    • MOODLE_20_STABLE
    • MDL-28963_Error_Writing_DB
    • Hide

      On a 1.9 site that includes modules not yet supported in 2.x, upgrade the site to 2.x. The modules with which we had problems were mod/kaltura and mod/extrafeatures. mod/wiziq and mod/wwwbdashboard caused a different but similar error due to the 'course' field not existing in their tables. After the upgrade, try to reset a course. If you get the error, it will be right after clicking Reset in the course's settings block. With the patch in place, you won't get an error and will be able to reset the course.

      If you don't get the error because you don't have any plugins with non-existent tables, you can simulate the same problem by just deleting (on a test site!) the table for any installed module. It will throw the same error since the table doesn't exist.

      Show
      On a 1.9 site that includes modules not yet supported in 2.x, upgrade the site to 2.x. The modules with which we had problems were mod/kaltura and mod/extrafeatures. mod/wiziq and mod/wwwbdashboard caused a different but similar error due to the 'course' field not existing in their tables. After the upgrade, try to reset a course. If you get the error, it will be right after clicking Reset in the course's settings block. With the patch in place, you won't get an error and will be able to reset the course. If you don't get the error because you don't have any plugins with non-existent tables, you can simulate the same problem by just deleting (on a test site!) the table for any installed module. It will throw the same error since the table doesn't exist.

      After upgrading a site to 2.x, an admin or teacher may receive an error, "Error writing to database," when attempting to reset a course. course/reset_form.php grabs a list of all modules from mdl_modules and then loops over them to count instances of each in the course. When a table with the module name doesn't exist or the table doesn't contain the expected 'course' field, an exception is thrown and the user receives an error. Expected behavior is to not receive an error and be able to reset the course.

      We tracked this down to the site having been upgraded from 1.9 to 2.0 and still having records in mdl_modules for modules that existed in 1.9 but haven't been updated for 2.0. To prevent the error and allow the user to reset the course, the simplest fix seems to be to wrap if (!$DB->count_records()) with a try/catch to catch the exception and continue to the next module. A patch is attached for that.

        1. lib_moodlelib2.patch
          2 kB
        2. reset_form_2.patch
          2 kB
        3. reset_form.patch
          1 kB

            skodak Petr Skoda
            cfollin Chris Follin
            Ankit Agarwal Ankit Agarwal
            Aparup Banerjee Aparup Banerjee
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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