I have a really big problem and can't find a solution yet, hope someone know what the issue might be.
I have 4 Logic Hooks inside a custom module.
<?php $hook_version = 1; $hook_array = Array(); $hook_array['after_relationship_add'] = Array(); $hook_array['after_relationship_add'] = Array( 1, 'custom 1', 'custom/modules/my_module/first_logic.php', 'first_logic', 'start_function' ); $hook_array['after_relationship_add'] = Array( 2, 'Custom 2.', 'custom/modules/my_module/second_logic.php', 'second_logic', 'start_function' ); $hook_array['after_relationship_add'] = Array( 3, 'Custom 3', 'custom/modules/my_module/third_logic.php', 'third_logic', 'start_function' ); $hook_array['before_relationship_delete'] = Array(); $hook_array['before_relationship_delete'] = Array( 1, 'Custom 4', 'custom/modules/my_module/anything.php', 'anything', 'start_function' );
each of the logic hooks i execute have their own validation at the beggining and they filter only for one kind of relationship. betwen my_module and another_specific_module.
The problem is that when i create a new record of my_module the first logic hook execute but it adds a new relationship, then it executes again because of the new relationship but this time it will return false and continue with second logic hook, this time according to the validations it may generate a new relationship to, and execute all three logic hooks again, after that it may go the third logic hook, but somehow it will break in execution. Im no sure in which moment but it stops and after reloading the page two of the same record will exist.
the sugarcrm.log sends this message twice:
[FATAL] Error inserting into table: my_module: Query Failed: INSERT INTO my_module .....
Also if i remove one of the logic hooks everything works great. Lets say I comment first one then second will execute OK or viceversa.
There is no moment when all 3 after_relationship_add hooks might execute, but 2 is very common and its when it breaks.