-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
3.7.5, 3.8.3
-
Any
-
MOODLE_37_STABLE, MOODLE_38_STABLE
During an upgrade from version 2019052003.06 to 2019052005.0 (Moodle v3.7)
The following error appears when trying to clean the competencies:
+ php admin/cli/upgrade.php --non-interactive
-->System
Default exception handler: Invalid user Debug: SELECT id FROM {user} WHERE id = ? AND deleted = ?
[array (
0 => '27',
1 => 0,
)]
Error code: invaliduser
- line 1562 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
- line 1538 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
- line 6395 of /lib/accesslib.php: call to moodle_database->get_record()
- line 3494 of /lib/db/upgrade.php: call to context_user::instance()
- line 1808 of /lib/upgradelib.php: call to xmldb_main_upgrade()
- line 187 of /admin/cli/upgrade.php: call to upgrade_core()
!!! Invalid user !!!
!! SELECT id FROM {user} WHERE id = ? AND deleted = ?
[array (
0 => '27',
1 => 0,
)]
The user is deleted in the users table (i.e. deleted = 1).
It does not have a corresponding context record at CONTEXT_USER level.
This line:
$context = context_user::instance($userevidence->userid);
tries to create the context record but context_user::instance() retrieves non-deleted users. Hence, the error.
The clean up was introduced in tracker: MDL-60126
As this is a clean up of broken data, I don't know how to reproduce the situation. I guess delete any context records for a test deleted user that has a record in the competency_userevidence table.
But, the code should catch this error and proceed with the next record.
Reasoning: creating a new context record is going to retrieve a new context ID. This ID is to be used in the delete_area_files(). As it is a new ID, it will not exist in the files - so does not make sense to use it.
Expected: upgrade script should proceed if delete user context is missing.
Actually Happening: an error is thrown and breaks the upgrade.
- is duplicated by
-
MDL-68683 Competency cleanup upgrade step causes DML exception when loading user context
-
- Closed
-