Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68716

Error with forum_discussionlistsortorder during privacy process

    XMLWordPrintable

    Details

      Description

      To reproduce:
      one user
      any kind of forum
      activated privacy settings
      1. Login as user
      2. Navigate to a course with any kind of forum
      3. Sorts the disskution list by name
      4. Requestes all data saved for him
      5. Run privacy cron task
      An email will be send with the error message:

      Argument 4 passed to core_privacy\local\request\writer::export_user_preference() must be of the type string, null given, called in /.../public_html/mod/forum/classes/privacy/provider.php on line 473

      #0 /.../public_html/mod/forum/classes/privacy/provider.php(473): core_privacy\local\request\writer::export_user_preference('mod_forum', 'forum_discussio...', '7', NULL)
      #1 /.../public_html/lib/moodlelib.php(8023): mod_forum\privacy\provider::export_user_preferences(9)
      #2 /.../public_html/privacy/classes/manager.php(578): component_class_callback('mod_forum
      priva...', 'export_user_pre...', Array)
      #3 /.../public_html/privacy/classes/manager.php(611): core_privacy\manager::component_class_callback('mod_forum', 'core_privacy
      lo...', 'export_user_pre...', Array)
      #4 /.../public_html/privacy/classes/manager.php(361): core_privacy\manager->handled_component_class_callback('mod_forum', 'core_privacy
      lo...', 'export_user_pre...', Array)
      #5 /.../public_html/admin/tool/dataprivacy/classes/task/process_data_request_task.php(114): core_privacy\manager->export_user_data(Object(core_privacy\local\request\contextlist_collection))
      #6 /.../public_html/lib/cronlib.php(284): tool_dataprivacy\task\process_data_request_task->execute()
      #7 /.../public_html/lib/cronlib.php(166): cron_run_inner_adhoc_task(Object(tool_dataprivacy\task\process_data_request_task))
      #8 /.../public_html/lib/cronlib.php(76): cron_run_adhoc_tasks(1589446639)
      #9 /.../public_html/admin/cron.php(81): cron_run()
      #10 {main}

       

      I tracked this message down to a switch in \mod\forum\classes\privacy\provider.php at line 446. Within this switch strings for the user preference forum_discussionlistsortorder are set.
      The problem seems to be the switch handles 6 cases and have no default set. But the preference has 12 different options.
      So when one of the missing options is set for the user the $discussionlistsortorderdescription is null and the call for export_user_preference in line 472 fails.

      The solution should be adding the missing cases and add a default case.

        Attachments

          Activity

            People

            Assignee:
            pholden Paul Holden
            Reporter:
            b.wolf82 Benjamin Wolf
            Peer reviewer:
            Amaia Anabitarte Amaia Anabitarte
            Integrator:
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Tester:
            CiBoT CiBoT
            Participants:
            Component watchers:
            Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/May/21

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 6 minutes
                3h 6m