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

Add $logextra parameter to restore_legacy() in base event class

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.9
    • Fix Version/s: None
    • Component/s: Events API
    • Labels:

      Description

      My patch in MDL-34867 included fixes to improve the performance of downloading log data where the parameter $logextra was added to the restore_legacy() function in the event base class so that additional course and user data could be passed. This is being addressed as a separate issue as the peer review suggested.
      The existing function restore() in the event base class also already accepts the $logextra argument. I've attached a patch for what these changes look like.

      New changes in lib/classes/event/base.php:

            * @param \stdClass $legacy
      +     * @param array $logextra Additional properties of the log
            * @return base
            */
      -    public static final function restore_legacy($legacy) {
      +    public static final function restore_legacy($legacy, array $logextra) {
               $classname = get_called_class();
               /** @var base $event */
               $event = new $classname();
      @@ -463,7 +464,7 @@ abstract class base implements \IteratorAggregate {
               $event->data['relateduserid'] = ($legacy->userid ? $legacy->userid : null);
               $event->data['timecreated'] = $legacy->time;
       
      -        $event->logextra = array();
      +        $event->logextra = $logextra;
      

      Existing $extralog parameter in lib/classes/event/base.php

          /**
           * Restore event from existing historic data.
           *
           * @param array $data
           * @param array $logextra the format is standardised by logging API
           * @return bool|\core\event\base
           */
          public static final function restore(array $data, array $logextra) {
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tbannister Tyler Bannister
              Reporter:
              tgus Tim Gus
              Peer reviewer:
              Ankit Agarwal Ankit Agarwal
              Integrator:
              Dan Poltawski Dan Poltawski
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: