From 70e2684dd5fc26befac6bba35313457a2a05c0ad Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 10 Aug 2011 13:03:51 +0000 Subject: [PATCH] fixed catchable fatal error ($old hast to be array or null) and avoid reading old contact twice --- addressbook/inc/class.addressbook_bo.inc.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 95ed0468da..fa8ac40d8a 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -879,7 +879,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']))) @@ -912,7 +915,7 @@ class addressbook_bo extends addressbook_so egw_link::notify_update('addressbook', $contact['id'], $contact); // Check for restore of deleted contact, restore held links - if($old['tid'] == addressbook_so::DELETED_TYPE && $contact['tid'] != addressbook_so::DELETED_TYPE) + if($old && $old['tid'] == addressbook_so::DELETED_TYPE && $contact['tid'] != addressbook_so::DELETED_TYPE) { egw_link::restore('addressbook', $contact['id']); } @@ -920,7 +923,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); } }