Index: branches/5.2.x/core/kernel/db/dbitem.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 13840) +++ branches/5.2.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 14092) @@ -1,6 +1,6 @@ saveCustomFields(); - - if ($affected_rows > 0) { - $this->raiseEvent('OnAfterItemUpdate'); - } - + $this->raiseEvent('OnAfterItemUpdate'); $this->OriginalFieldValues = $this->FieldValues; $this->Loaded = true; @@ -933,7 +929,7 @@ } } else { - if (($field_name == $this->IDField) && ($field_value == 0)) { + if (($field_name == $this->IDField) && ($field_value == 0) && !is_int($force_id)) { // don't skip IDField in INSERT statement, just use DEFAULT keyword as it's value $values_sql .= 'DEFAULT'; } @@ -972,7 +968,7 @@ $this->Application->resetCounters($this->TableName); } - if ($this->IsTempTable() && ($this->Application->GetTopmostPrefix($this->Prefix) != $this->Prefix)) { + if ($this->IsTempTable() && ($this->Application->GetTopmostPrefix($this->Prefix) != $this->Prefix) && !is_int($force_id)) { // temp table + subitem = set negative id $this->setTempID(); } @@ -1410,12 +1406,14 @@ /** * Returns only changed database field * + * @param bool $include_virtual_fields * @return Array */ - function GetChangedFields() + function GetChangedFields($include_virtual_fields = false) { $changes = Array (); - $diff = array_diff_assoc($this->GetRealFields(), $this->OriginalFieldValues); + $fields = $include_virtual_fields ? $this->FieldValues : $this->GetRealFields(); + $diff = array_diff_assoc($fields, $this->OriginalFieldValues); foreach ($diff as $field => $new_value) { $old_value = $this->GetOriginalField($field, true);