nicusX / moodle-mod_attendanceregister

Attendance Register activity module for Moodle 2
12 stars 17 forks source link

cron terminates on DB error after update to version 2013032201 #48

Closed pavelxkrejci closed 11 years ago

pavelxkrejci commented 11 years ago

Hello, there is 1 instance of this plugin used on my server.

The update itself from Moodle admin UI went fine. However since then the cron started to crash with this debug output:

Processing module function attendanceregister_cron ...Updating AttendanceRegiste Calculating new sessions of AttendanceRegister ID 1... Found 6 Users whose AttendanceRegister Sessions need updating !!! Error writing to database !!! !! Column 'onlinesess' cannot be null INSERT INTO mdl_attendanceregister_aggregate (register,userid,onlinesess,refcourse,duration,total,grandtotal,lastsessionlogout) VALUES(?,?,?,?,?,?,?,?) [array ( 0 => '1', 1 => '46', 2 => NULL, 3 => NULL, 4 => '5485233', 5 => '0', 6 => '1', 7 => '1351849240', )] Error code: dmlwriteexception !! !! Stack trace:

nicusX commented 11 years ago

I'm unable to reproduce this bug. Something should have gone wrong in your installation. Apparently, in your database column mod_aggregate->onlinesess is NOT NULL, but in module schema definition (install.xml) it is nullable,

This column never changed its definition in previous versions, but it was renamed from "online" to "onlinesess" in 2013020604 version, remaining nullable. Maybe in your installation something goes wrong in that upgrade, incorrectly changing that column to NOT NULL (I don't know why, as upgrading worked in my MySQL installation).

To work around the problem I suggest to manually fix the column definition, using a SQL statement like this:

ALTER TABLE `mdl_attendanceregister_aggregate`
  MODIFY `onlinesess` tinyint(1) unsigned DEFAULT '1';