Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid "duplicate value x found in column 'userid'" in recompletion task #152

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

jonof
Copy link
Contributor

@jonof jonof commented Feb 22, 2024

A user who is to be reset in multiple courses within the same 'check_recompletion' task cycle will cause a "Did you remember to make the first column something unique in your call to get_records?" warning to be logged due their userid being returned in multiple records as the first column of the row. This results in one course being reset and the rest being skipped, which I imagine could be an issue for scheduled resets of courses that happen only once a year.

e.g.

Execute scheduled task: Check for users that need to recomplete (local_recompletion\task\check_recompletion)
... started 12:28:26. Current memory use 17.6 MB.
++ Did you remember to make the first column something unique in your call to get_records? Duplicate value '5' found in column 'userid'. ++
* line 1407 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
* line 78 of /local/recompletion/classes/task/check_recompletion.php: call to mysqli_native_moodle_database->get_records_sql()
* line 100 of /local/recompletion/classes/task/check_recompletion.php: call to local_recompletion\task\check_recompletion->get_user_courses_to_reset()
* line 405 of /lib/classes/cron.php: call to local_recompletion\task\check_recompletion->execute()
* line 198 of /admin/cli/scheduled_task.php: call to core\cron::run_inner_scheduled_task()
... used 50 dbqueries
... used 0.53339600563049 seconds
Scheduled task complete: Check for users that need to recomplete (local_recompletion\task\check_recompletion)

This problem can be avoided by including course_completions.id as the first returned column.

@danmarsden danmarsden merged commit 4db4c6f into danmarsden:MOODLE_403_STABLE Feb 23, 2024
7 checks passed
@danmarsden
Copy link
Owner

thanks heaps for the PR! - I've cherry-picked that into the 4.1 stable branch as well.

@jonof jonof deleted the task-unique-ids branch May 12, 2024 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants