1st you should wite 'true' insted of true.
2nd there is a bug in /include/database/DBHelper.php:
The function getDataChanges only tests changes of fields which are columns in <bean> and <bean>_cstm tables (listed in fetched_row array), not the related fields (listed in rel_fields_before_value array)!
I made a simple quick change (without any guarantees!) of this function by duplicating the code.
In the new PATCH code not only the fetched_rows array is checked but also the rel_fields_before_value array.
Code:
function getDataChanges(&$bean) {
$changed_values=array();
$audit_fields=$bean->getAuditEnabledFieldDefinitions();
if (is_array($audit_fields) and count($audit_fields) > 0) {
foreach ($audit_fields as $field=>$properties) {
if (!empty($bean->fetched_row) && array_key_exists($field, $bean->fetched_row)) {
$before_value=$bean->fetched_row[$field];
$after_value=$bean->$field;
if (isset($properties['type']))
$field_type=$properties['type'];
else {
if (isset($properties['dbType']))
$field_type=$properties['dbType'];
else if(isset($properties['data_type']))
$field_type=$properties['data_type'];
else
$field_type=$properties['dbtype'];
}
//if the type and values match, do nothing.
if (!(emptyValue($before_value,$field_type) && emptyValue($after_value,$field_type))) {
if (trim($before_value) !== trim($after_value)) {
if (!(isTypeNumber($field_type) && (trim($before_value)+0) == (trim($after_value)+0))) {
if (!(isTypeBoolean($field_type) && (getBooleanValue($before_value)== getBooleanValue($after_value)))) {
$changed_values[$field]=array('field_name'=>$field,
'data_type'=>$field_type,
'before'=>$before_value,
'after'=>$after_value);
}
}
}
}
}
//PATCH BEGIN KUSKE_151
if (!empty($bean->rel_fields_before_value) && array_key_exists($field, $bean->rel_fields_before_value)) {
$before_value=$bean->rel_fields_before_value[$field];
$after_value=$bean->$field;
if (isset($properties['type']))
$field_type=$properties['type'];
else {
if (isset($properties['dbType']))
$field_type=$properties['dbType'];
else if(isset($properties['data_type']))
$field_type=$properties['data_type'];
else
$field_type=$properties['dbtype'];
}
//if the type and values match, do nothing.
if (!(emptyValue($before_value,$field_type) && emptyValue($after_value,$field_type))) {
if (trim($before_value) !== trim($after_value)) {
if (!(isTypeNumber($field_type) && (trim($before_value)+0) == (trim($after_value)+0))) {
if (!(isTypeBoolean($field_type) && (getBooleanValue($before_value)== getBooleanValue($after_value)))) {
$changed_values[$field]=array('field_name'=>$field,
'data_type'=>$field_type,
'before'=>$before_value,
'after'=>$after_value);
}
}
}
}
}
//PATCH END KUSKE_151
}
}
return $changed_values;
} I changed this in version 4.5.1h, I do not know yet whether the bug is in 5.0.0 too....
Bookmarks