fixed catchable fatal error ($old hast to be array or null) and avoid reading old contact twice

This commit is contained in:
Ralf Becker 2011-08-10 13:05:16 +00:00
parent b566832f15
commit d86e063e22

View File

@ -836,7 +836,10 @@ class addressbook_bo extends addressbook_so
}
// Get old record for tracking changes
$old = $this->data2db($this->read($contact['id']));
if (!isset($old) && $isUpdate)
{
$old = $this->read($contact['id']);
}
// IF THE OLD ENTRY IS A ACCOUNT, dont allow to change the owner/location
// maybe we need that for id and account_id as well.
if (is_array($old) && (!isset($old['owner']) || empty($old['owner'])))
@ -871,7 +874,7 @@ class addressbook_bo extends addressbook_so
// Record change history for sql - doesn't work for LDAP accounts
if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') {
$deleted = ($old['tid'] == addressbook_so::DELETED_TYPE || $contact['tid'] == addressbook_so::DELETED_TYPE);
$this->tracking->track($to_write, $old, null, $deleted);
$this->tracking->track($to_write, $old ? $old : null, null, $deleted);
}
}