We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Custom Events Manager in Phalcon\MVC\Models throws errors

Guys,

I've described the problem here:

https://stackoverflow.com/questions/19082505/custom-events-manager-in-phalcon-mvc-models-throws-errors

Appreciate your help.

Thanks, Temuri

P.S. Looks like it craps out when Model's ->_modelsManager->_customEventsManager is set.



51.4k

OK, after 6 hours of digging I found that problem occurs in the following block:


static PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent){
    if (phalcon_array_isset(custom_events_manager, entity_name)) {

        PHALCON_INIT_NVAR(fire_event_name);
        PHALCON_CONCAT_SV(fire_event_name, "mTodel:", event_name);

        PHALCON_INIT_NVAR(status);

        phalcon_call_method_p2_key(status, custom_events_manager, "fire", 210712414539UL, fire_event_name, model);

        if (PHALCON_IS_FALSE(status)) {
            RETURN_CCTOR(status);
        }
    }
}

Firing "model:beforeValidation" event crashes execution.

When calling phalcon_call_method_p2_key() method, "custom_events_manager" is not an object - it is an array, where model is indexed by array key name ("entity_name" here?).

Thus, shouldn't be call made on the "custom_events_manager->entity_name" ?

Thanks!



98.9k

This is fixed in 1.3.0