General developer forum

Event not triggered anymore in local plugin

 
Picture of Julien Thomas
Event not triggered anymore in local plugin
 

Hello !

I created a local plugin which trigger multiple core events and everything was working correctely until today.

I did no particular changes to my code, and I can't fix this.

I purged cache multiple times without success.


That's the event related files of the plugin :


In /db/events.php

defined('MOODLE_INTERNAL') || die();

$observers = array(
    
    array(
        'eventname' => '\core\event\user_enrolment_created',
        'callback'  => '\local_cible\event_observer::user_enrolled',
    ),
    
    array(
        'eventname' => '\core\event\user_enrolment_deleted',
        'callback'  => '\local_cible\event_observer::user_unenrolled',
    ), 
    
    array(
        'eventname' => '\core\event\user_updated',
        'callback'  => '\local_cible\event_observer::user_updated',
    ),
    
    array(
        'eventname' => '\core\event\group_deleted',
        'callback'  => '\local_cible\event_observer::group_deleted',
    ),
    
);


In /classes/event_observer.php

namespace local_cible;
defined('MOODLE_INTERNAL') || die();
class event_observer {
    public static function user_enrolled(\core\event\user_enrolment_created $event) { ... }
    public static function user_unenrolled(\core\event\user_enrolment_deleted $event) { ... }
    public static function user_updated(\core\event\user_updated $event) { ... }
    public static function group_deleted(\core\event\group_deleted $event) { ... }
}

It there something wrong with this code ?


Thank you.


 
Average of ratings: -
Picture of Julien Thomas
Re: Event not triggered anymore in local plugin
 

In fact it seems that events are not always triggered when the webservice call the folowing function :

  • enrol_manual_enrol_users
  • enrol_manual_unenrol_users


 
Average of ratings: -
Picture of Julien Thomas
Re: Event not triggered anymore in local plugin
 

After some other tests, it seems that nothing triggers because instead of unenrolling student, the webservice only disable it.

It's weird!

 
Average of ratings: -