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

Observer method is triggered on child events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.9.19, 3.11.11, 4.0.5, 4.1
    • Events API
    • None
    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE

      If you have an observer to listen to one event, but it also gets triggered when a child event of the expected event is triggered.

      Like in my case class grade_item_updated extends grade_item_created. My observer is looking for grade_item_created, but still catches grade_item_updated.

      So 

       

      $observers = [
      [
      'eventname' => '\core\event\grade_item_created',
      'callback' => '\local_submissionrestrict\observer::handle_grade_item_created'
      ]
      ];
       
      

      will also catch grade_item_updated.

      Steps to replicate:

      1. Install https://github.com/catalyst/moodle-local_submissionrestrict
      2. Create a course
      3. Create an assignment activity.  
      4. Trigger duplication of the activity and observe that handle_grade_item_created method is triggered twice in https://github.com/catalyst/moodle-local_submissionrestrict/blob/MOODLE_39_STABLE/classes/observer.php#L40 but events are different type. 

            Unassigned Unassigned
            dmitriim Dmitrii Metelkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.