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

Add loginas support to cron_setup_user

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: None
    • Component/s: Tasks
    • Labels:
    • Affected Branches:
      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

              • Assignee:
                Unassigned
                Reporter:
                dmonllao David Monllaó
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: