drachels / moodle-mod_mootyper

4 stars 18 forks source link

\tool_dataprivacy\task\process_data_request_task fails on mod_mootyper #104

Closed dasistwas closed 1 year ago

dasistwas commented 2 years ago

When a user requests to export the data with the data privacy api, an adhoc task is created. This task fails due to this error:

Fatal error: Declaration of mod_mootyper\privacy\provider::get_metadata(core_privacy\local\metadata\collection $collection) must be compatible with core_privacy\local\metadata\provider::get_metadata(core_privacy\local\metadata\collection $collection): core_privacy\local\metadata\collection in /mod/mootyper/classes/privacy/provider.php on line 65

Call Stack:
    0.0002     401688   1. {main}() /admin/cli/adhoc_task.php:0
    0.1659   16772952   2. cron_run_adhoc_tasks() /admin/cli/adhoc_task.php:131
    0.4899   24004016   3. cron_run_inner_adhoc_task() /lib/cronlib.php:198
    0.4912   24034488   4. tool_dataprivacy\\task\\process_data_request_task->execute() /lib/cronlib.php:341
    0.4980   24812320   5. core_privacy\\manager->get_contexts_for_userid() /admin/tool/dataprivacy/classes/task/process_data_request_task.php:94
   14.5233   43342480   6. core_privacy\\manager->handled_component_class_callback() /privacy/classes/manager.php:238
   14.5233   43342480   7. core_privacy\\manager::component_class_callback() /privacy/classes/manager.php:611
   14.5233   43342536   8. class_exists() /privacy/classes/manager.php:577
   14.5233   43342536   9. spl_autoload_call() /privacy/classes/manager.php:577
   14.5233   43342536  10. core_component::classloader() /privacy/classes/manager.php:577
   14.5239   43395184  11. include_once(\'/mod/mootyper/classes/privacy/provider.php\') /lib/classes/component.php:136

This breaks the whole data export for users and thus any platform using this module is not GDPR compliant anymore.

dasistwas commented 2 years ago

Moodle version: 3.10 mootyper version:

$plugin->version   = 2022012700;      // The current module version (Date: YYYYMMDDXX).
$plugin->requires  = 2017111300;      // Requires Moodle 3.4.
$plugin->cron      = 60;              // Period for cron to check this module (secs).
$plugin->component = 'mod_mootyper';
$plugin->maturity  = MATURITY_STABLE;
$plugin->release   = '4.1.1 (Build: 2022012700)';
dasistwas commented 2 years ago

Fix: mod/mootyper/classes/privacy/provider.php

@@ -62,7 +62,7 @@ class provider implements
     * @param collection $collection The initialised collection to add items to.
     * @return collection The updated collection of metadata items.
     */
    public static function get_metadata(collection $collection) {
    public static function get_metadata(collection $collection) : collection {
        $collection->add_database_table('mootyper_attempts', [
            'mootyperid' => 'privacy:metadata:mootyper_attempts:mootyperid',
            'userid' => 'privacy:metadata:mootyper_attempts:userid',
@@ -115,7 +115,7 @@ private static function get_modid() {
     * @param int $userid The user to search for.
     * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
     */
    public static function get_contexts_for_userid(int $userid) {
    public static function get_contexts_for_userid(int $userid) : contextlist {
        $contextlist = new contextlist();
        $modid = self::get_modid();
        if (!$modid) {
drachels commented 2 years ago

Thank you for the information. I will work on it as soon as I can.

drachels commented 2 years ago

Just to let you know, I have been having some personal health issues and have not had much time to work on this. I had made the needed code changes back when David first opened this issue, but had not had the time to create a new release due to other things I was working on. I will try to make a release within the next week.

drachels commented 1 year ago

The fix for this was included in the MooTyper v4.1.2 version so closing this issue.