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

Error when deleting data for user #86

Open
monnardj opened this issue Oct 24, 2023 · 2 comments
Open

Error when deleting data for user #86

monnardj opened this issue Oct 24, 2023 · 2 comments

Comments

@monnardj
Copy link

monnardj commented Oct 24, 2023

When a user is deleted from Moodle, a data deletion request is created. And when this request is processed by the cron job, an error is raised :

Error writing to database

#0 /var/www/htdocs/lib/dml/moodle_read_slave_trait.php(293): moodle_database->query_end()
#1 /var/www/htdocs/lib/dml/mysqli_native_moodle_database.php(1703): mysqli_native_moodle_database->query_end()
#2 /var/www/htdocs/mod/hotquestion/classes/privacy/provider.php(366): mysqli_native_moodle_database->delete_records_select()
#3 /var/www/htdocs/lib/moodlelib.php(8144): mod_hotquestion\privacy\provider::delete_data_for_user()
#4 /var/www/htdocs/privacy/classes/manager.php(578): component_class_callback()
#5 /var/www/htdocs/privacy/classes/manager.php(611): core_privacy\manager::component_class_callback()
#6 /var/www/htdocs/privacy/classes/manager.php(415): core_privacy\manager->handled_component_class_callback()
#7 /var/www/htdocs/admin/tool/dataprivacy/classes/task/process_data_request_task.php(138): core_privacy\manager->delete_data_for_user()
#8 /var/www/htdocs/lib/cronlib.php(367): tool_dataprivacy\task\process_data_request_task->execute()
#9 /var/www/htdocs/lib/cronlib.php(198): cron_run_inner_adhoc_task()
#10 /var/www/htdocs/lib/cronlib.php(76): cron_run_adhoc_tasks()
#11 /var/www/htdocs/admin/cli/cron.php(178): cron_run()
#12 {main}

Looking at the code, there seems to be an error in /classes/privacy/provider.php at line 366. An SQL query is executed on table 'hotquestion_votes' which references field 'userid'. But this table contains no such field. The field for the user id in this table is apparently called 'voter'.

The SQL query at line 366 should be modified accordingly (note that tables 'hotquestion_questions' and 'hotquestion_grades' do have a field 'userid', which is used correctly at line 368 in the same file).

Edit : lines 407-409 also contain invalid field names from table 'hotquestion_votes'. They use 'userid' and 'itemid', which both don't exist in the table.

@drachels
Copy link
Owner

drachels commented Oct 24, 2023

I have been trying to find the time to go back through the provider.php file for quite some time now, but have been too busy with other things, and I have also been sick a lot this year, especially had a lot of problems with my eyes.

I see the error you pointed out and it looks like probably the same type of error in line 408. I think I also forgot to see if there is anything I need to do to handle any comments made by a user on some question. I will have to dig back through my ticket system and see what I can find out.

I will try to work on this file as much as I can, but it might take a couple of days. My eyes started bothering me again yesterday, but hopefully I detected it early enough and started treatment so that maybe I will not have to spend any days sitting in a darkened room doing nothing.

@drachels
Copy link
Owner

Just pushed changes in provider.php lines 366 and 408 to the master branch. I have only had time to test for personal data export so far which looked okay. Have not tested for a delete request just yet. I need to add some more student data to my new test site, and will not get to that until tomorrow.

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

No branches or pull requests

2 participants