-
Bug
-
Resolution: Fixed
-
Minor
-
4.1.13, 4.5
It's currently possible to set the fields "sortorder" and "descriptionformat" in mdl_customfield_field" and "mdl_customfield_category" to NULL. This happened for me when I installed 3rd party plugins in Moodle that add custom fields.
When either "sortorder" and/or "descriptionformat" is NULL, I'm getting the following error (Moodle 4.1):
sortorder: Data submitted is invalid
Error code: invalidpersistenterror
- line 558 of /lib/classes/persistent.php: core\invalid_persistent_exception thrown
- line 607 of /lib/classes/persistent.php: call to core\persistent->update()
- line 194 of /customfield/classes/field_controller.php: call to core\persistent->save()
- line 200 of /customfield/classes/api.php: call to core_customfield\field_controller->save()
- line 324 of /customfield/classes/handler.php: call to core_customfield\api::move_field()
- line 250 of /customfield/externallib.php: call to core_customfield\handler->move_field()
- line 262 of /lib/externallib.php: call to core_customfield_external::move_field()
- line 81 of /lib/ajax/service.php: call to external_api::call_external_function()
I can reproduce this error in Moodle 4.1 and also in current dev version of 4.5. In my opinion, the either the database fields should've set to either "NOT NULL" or NULL values should be handled on PHP side instead of throwing an error.