In adding my own custom logic hooks for relationships, I determined that Sugarbean is unnecessarily deleting and re-adding relationships during Save() even when no relationship changes were made. This is because there is no test that checks for the change before the Link delete/add functions are called.
I posted this as Bug #31775 and labeled this a defect because of the unnecessary overhead this puts on so many aspects of the system.
Here is the diff output from a change I made to SugarBean.php (5.2.0f) to correct this issue:
Code:1858,1864c1858 < $rel_changed = 1; < // EJG Update to check for relationship change < if($this->rel_fields_before_value[$def['id_name']] == $this->$def['id_name']) { < $rel_changed = 0; < } < // EJG End < if ($rel_changed && !empty($this->rel_fields_before_value[$def [ 'id_name' ]])) --- > if (!empty($this->rel_fields_before_value[$def [ 'id_name' ]])) 1866d1859 < 1873c1866 < if ($rel_changed && !empty($this->$def['id_name']) && is_string($this->$def['id_name'])) --- > if (!empty($this->$def['id_name']) && is_string($this->$def['id_name']))


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks