Errors from deleting new course after upgrade to 2.0.4

Errors from deleting new course after upgrade to 2.0.4

by John White -
Number of replies: 1

Hi all,

We are still running trial conversions of copies of our entire dataset (db, and all files) from version 1.9.12 to 2.0.4. We've even fixed (I hope) faults with the wiki conversion (but only from ewiki to nwiki in Moodle 2). BUT I have a bug! With debug still switched on in config.

After the conversion I created a new course, just an empty dummy course, no users (except those who enherited a role from the category), and no content. IT ALL WORKED FINE! Then I deleted the course. A load of errors as follows...

 

Debug info: Column 'decimals' cannot be null
INSERT INTO mdl_grade_items_history (courseid,categoryid,itemname,itemtype,itemmodule,iteminstance,itemnumber,iteminfo,
idnumber,calculation,gradetype,grademax,grademin,scaleid,outcomeid,gradepass,
multfactor,plusfactor,aggregationcoef,sortorder,display,decimals,locked,locktime,
needsupdate,timemodified,hidden,action,oldid,source,loggeduser) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
array (
0 => '1139',
1 => NULL,
2 => NULL,
3 => 'course',
4 => NULL,
5 => '1005',
6 => NULL,
7 => NULL,
8 => NULL,
9 => NULL,
10 => '1',
11 => '100.00000',
12 => '0.00000',
13 => NULL,
14 => NULL,
15 => '0.00000',
16 => '1.00000',
17 => '0.00000',
18 => '0.00000',
19 => '1',
20 => '0',
21 => NULL,
22 => '0',
23 => '0',
24 => '1',
25 => 1312922136,
26 => '0',
27 => 1,
28 => '5016',
29 => 'system',
30 => '4309',
)]
Stack trace:
line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 878 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 920 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 319 of /lib/grade/grade_object.php: call to mysqli_native_moodle_database->insert_record()
line 403 of /lib/grade/grade_item.php: call to grade_object->insert()
line 1268 of /lib/grade/grade_category.php: call to grade_item->insert()
line 1241 of /lib/grade/grade_category.php: call to grade_category->get_grade_item()
line 212 of /lib/grade/grade_category.php: call to grade_category->load_grade_item()
line 380 of /lib/grade/grade_category.php: call to grade_category->update()
line 1454 of /lib/grade/grade_category.php: call to grade_category->insert_course_category()
line 1224 of /lib/gradelib.php: call to grade_category::fetch_course_category()
line 4032 of /lib/moodlelib.php: call to remove_course_grades()
line 3964 of /lib/moodlelib.php: call to remove_course_contents()
line 73 of /course/delete.php: call to delete_course()
Of course, the debug tree itself has to be read backwards.
So plainly deleting the course sets off a chain reaction, which appears to want to CONTRUCT grades, when if fact if there were any they would be removed (?). But there are no grades to remove!
Has anyone else seen this error since conversion?
Regards, John.
Average of ratings: -
In reply to John White

Re: Errors from deleting new course after upgrade to 2.0.4

by John White -

Hi all,

I've now worked out what this is about and I see this now as a minor bug so I'll put up a tracker item about it if I can't find one already.

The problem is simply this... Whereas in table mdl_grade_items the 'decimals' field permits a NULL value, as it should, in table mdl_grade_items_history this is NOT permitted (and indeed I think should NOT be) but no default value is set in the conversion process. This is faulty. My reasoning is that a grade item in mdl_grade_items will either have 'decimals' set to the required number of decimal places for that item or be left as NULL meaning that the value is plucked from the course or site settings of 'decimalpoints' (note, not decimalplaces); whereas in mdl_grade_items_history the number of decimal places set should already be a known value (this is history after all). So I suspect that a NULL value here is inappropriate as it should be a value 0 to 5 inclusive; hence the NOT NULL setting, however, the line as quoted above 21=>NULL tries to force a NULL into this field!

I believe it is only necessary to set the default value for 'decimals' in mdl_grade_items_history to 0 to fix this.

Now at MDL-29089

Regards, John