[Vtigercrm-developers] Infinite loop in Events

David V. davidv.net at gmail.com
Sat Mar 27 04:32:29 PDT 2010


MAK,

It works perfectly !!!

For future reference I wanted to make clear that in the example provided by
MAK, HelpDesk is the module from wich you are saving and NOT the target
module in wich you want the new entity to be created.
David V.


2010/3/26 David V. <davidv.net at gmail.com>

> Thank you MAK,
>
> I'll try that.
>
> David V.
>
>
> 2010/3/26 Musavir Khan <musavir at vtiger.com>
>
> Hi David,
>>
>> you the type of entity for which the event is trigger and type of entity
>> that is being created in the event handler then you can add a check for
>> module name something like this should work,
>>
>> function handleEvent($eventName, $entityData) {
>>         global $log, $adb;
>>
>>         if($eventName == 'vtiger.entity.beforesave') {
>>             $moduleName = $entityData->getModuleName();
>>             if ($moduleName == 'HelpDesk') {
>>                 //your code here
>>            }
>>       }
>> }
>>
>> This should avoid the infinite recursion, but if the entity being created
>> and the entity for which the event is of same type then this will not
>> work.
>>
>> Thanks,
>> MAK
>>
>>
>>
>> On Fri, Mar 26, 2010 at 5:18 PM, Joe Bordes <joe at tsolucio.com> wrote:
>>
>>>  FYI: We ended up not using it and doing events the "old" way (coding).
>>> It's faster but creates dependencies.
>>>
>>> In any case I expect this (and workflows) to get a lot better in next
>>> releases and start using it then.
>>>
>>> This my experience, I am VERY comfortable with the code, so I tend to go
>>> there for solutions.
>>>
>>> Joe
>>> TSolucio
>>>
>>> El 26/03/10 12:41, David V. escribió:
>>>
>>> Hi Everybody !
>>>
>>> According to this ticket :
>>> http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/5468
>>>
>>> "When you add an aftersave event to an entity and in the HandleEvent?<http://trac.vtiger.com/cgi-bin/trac.cgi/wiki/HandleEvent>you create (and save) another entity, it raises an infinite loop.
>>>
>>> This occurs because VTEvenTrigger::trigger
>>> (include/events/VTEventTrigger.inc), execute all handlers registered when
>>> saving an entity. It should execute ONLY handler for current entity"
>>> According to the same ticket the solution is :
>>>
>>> "This is something the developer will have to handle in their own code.
>>> There are events that will have to run on every save."
>>>
>>> But how do we actually handle this in the code ?
>>>
>>> Does anyone have a working example of how to avoid infinite loop without
>>> modifying Vtiger core ?
>>>
>>> Thank you very much.
>>>
>>> David V.
>>>
>>>
>>> _______________________________________________
>>> Reach hundreds of potential candidates - http://jobs.vtiger.com
>>>
>>>
>>>
>>> --
>>> Un saludo
>>> Joe
>>> TSolucio
>>>
>>>
>>> _______________________________________________
>>> Reach hundreds of potential candidates - http://jobs.vtiger.com
>>>
>>
>>
>> _______________________________________________
>> Reach hundreds of potential candidates - http://jobs.vtiger.com
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20100327/8a119595/attachment-0002.html 


More information about the vtigercrm-developers mailing list