Getting Error when trying to add a file

Getting Error when trying to add a file

by Олексій Буренко -
Number of replies: 7

Hello

1. When I try to add a file (1.docx for example) to a course by dragging with the mouse (drag and drop) I get an error


2. But when I add the same file through the menu Add an activity or resource - its ok, file adding

In first case I get error in PHP:

[19-Jul-2022 16:27:59 Europe/Kiev] Default exception handler: Error writing to the database Debug: Field 'idnumber' doesn't have a default value

INSERT INTO mdl_course_modules (section,visible,course,module,groupmode,groupingid,instance,completion,completionview,added) VALUES(?,?,?,?,?,?,?,?,?,?)

[array (

  0 => 1,

  1 => '1',

  2 => '2651',

  3 => '17',

  4 => '0',

  5 => '0',

  6 => 0,

  7 => 1,

  8 => 1,

  9 => 1658237279,

)]

Error code: dmlwriteexception

* line 489 of \lib\dml\moodle_database.php: dml_write_exception thrown

* line 1357 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()

* line 1403 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()

* line 692 of \course\lib.php: call to mysqli_native_moodle_database->insert_record()

* line 567 of \course\dnduploadlib.php: call to add_course_module()

* line 504 of \course\dnduploadlib.php: call to dndupload_ajax_processor->create_course_module()

* line 476 of \course\dnduploadlib.php: call to dndupload_ajax_processor->handle_file_upload()

* line 41 of \course\dndupload.php: call to dndupload_ajax_processor->process()

Has anyone encountered such a problem?

Can it be solved somehow?

This issue has been observed from version to version of Moodle. The update didn't help.

The current version of Moodle is 3.11.2+ (Build: 20210827)


Average of ratings: -
In reply to Олексій Буренко

Re: Getting Error when trying to add a file

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This actually sounds like the definition of your mdl_course_modules table is incorrect. In my 3.11, field 'idnumber' definitely does have a default value (it's 'null').

So... your next step is to perform a schema check.

See https://docs.moodle.org/311/en/Verify_Database_Schema
Average of ratings: Useful (3)
In reply to Howard Miller

Re: Getting Error when trying to add a file

by Олексій Буренко -
This is result
php admin/cli/check_database_schema.php
-------------------------------------------------------------------------------
course_modules
* column 'idnumber' should allow NULL (C)
-------------------------------------------------------------------------------
grade_items
* column 'courseid' should allow NULL (I)
-------------------------------------------------------------------------------
game
* column 'introformat' should be NOT NULL (I)
-------------------------------------------------------------------------------
game_queries
* column 'mycol' has default '0', expected 'NULL' (I)
* column 'myrow' has default '0', expected 'NULL' (I)
-------------------------------------------------------------------------------
game_cross
* column 'usedcols' has default '0', expected 'NULL' (I)
* column 'usedrows' has default '0', expected 'NULL' (I)
* column 'createscore' should allow NULL (N)
* column 'cols' is not expected (I)
* column 'rows' is not expected (I)
-------------------------------------------------------------------------------
game_snakes_database
* column 'usedcols' has default '0', expected 'NULL' (I)
* column 'usedrows' has default '0', expected 'NULL' (I)
* column 'cols' is not expected (I)
* column 'rows' is not expected (I)
-------------------------------------------------------------------------------
In reply to Howard Miller

Re: Getting Error when trying to add a file

by Олексій Буренко -
Thanks a lot, problem solved
ALTER TABLE mdl_course_modules MODIFY idnumber varchar(100) NULL;
ALTER TABLE mdl_grade_items MODIFY courseid bigint(10) NULL;
In reply to Олексій Буренко

Re: Getting Error when trying to add a file

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Like that smile

As an aside, it's a good idea for *everybody* to check this once in a while if they have upgraded a number of times.
Average of ratings: Useful (1)
In reply to Олексій Буренко

Re: Getting Error when trying to add a file

by Олексій Буренко -

hi,

I didn't figure out how to fix the errors, can someone help me ??

game_cross

 * column 'cols' is not expected (I)

 * column 'rows' is not expected (I)

-------------------------------------------------------------------------------

game_snakes_database

 * column 'cols' is not expected (I)

 * column 'rows' is not expected (I)

Do these columns just need to be removed?

column 'cols' 

column 'rows'

In reply to Олексій Буренко

Re: Getting Error when trying to add a file

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I believe so. If you're keen, you could raise this as a bug with the game plugin. There must be something missing in the upgrade scripts.


But the rows and cols fields are added and manipulated in https://github.com/bdaloukas/moodle-mod_game/blob/MOODLE_20_STABLE/db/upgrade.php

...but don't ever seem to have been removed again. A minor bug. 
Average of ratings: Useful (1)