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

Add loginas support to cron_setup_user

    XMLWordPrintable

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.1.2
    • None
    • Tasks
    • MOODLE_31_STABLE

    Description

      I'm adding a patch to MDL-54751 to set the proper user when executing a adhoc task in background. I send both realuser and userid, cron_setup_user could accept a $realuser param and do something like what I'm pasting below.

      This is the logic I am adding to course_delete_modules task should be replaced by cron_setup_user($user, $context, $realuser) (or something similar) if we end up working on this.

              if ($this->get_custom_data()->userid !== $this->get_custom_data()->realuserid) {
                  $realuser = $DB->get_record('user', array('id' => $this->get_custom_data()->realuserid));
                  cron_setup_user($realuser);
                  \core\session\manager::loginas($this->get_custom_data()->userid, \context_system::instance(), false);
              } else {
                  $user = $DB->get_record('user', array('id' => $this->get_custom_data()->userid));
                  cron_setup_user($user);
              }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dmonllao David Monllaó
              David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: