diff --git a/CRM/I3val/Handler/AddressUpdate.php b/CRM/I3val/Handler/AddressUpdate.php index aeac3c1..4484163 100644 --- a/CRM/I3val/Handler/AddressUpdate.php +++ b/CRM/I3val/Handler/AddressUpdate.php @@ -517,28 +517,25 @@ protected function getCountryList() { */ protected function getExistingAddresses($contact_id) { // load all addresses - static $addresses = NULL; - if ($addresses === NULL) { - try { - $query = civicrm_api3('Address', 'get', [ - 'contact_id' => $contact_id, - 'option.limit' => 0, - 'option.sort' => 'is_primary desc', - 'sequential' => 1]); - $addresses = []; - - // enrich data - foreach ($query['values'] as $address) { - $this->resolveFields($address); - if (isset($addresses[$address['location_type_id']])) { - throw new Exception("Contact [{$contact_id}] has multiple addresses for location type '{$address['location_type']}'. Please fix!"); - } else { - $addresses[$address['location_type_id']] = $address; - } + $addresses = []; + try { + $query = civicrm_api3('Address', 'get', [ + 'contact_id' => $contact_id, + 'option.limit' => 0, + 'option.sort' => 'is_primary desc', + 'sequential' => 1]); + + // enrich data + foreach ($query['values'] as $address) { + $this->resolveFields($address); + if (isset($addresses[$address['location_type_id']])) { + throw new Exception("Contact [{$contact_id}] has multiple addresses for location type '{$address['location_type']}'. Please fix!"); + } else { + $addresses[$address['location_type_id']] = $address; } - } catch (Exception $ex) { - throw new Exception("Error while loading addresses for contact [{$contact_id}]: " . $ex->getMessage()); } + } catch (Exception $ex) { + throw new Exception("Error while loading addresses for contact [{$contact_id}]: " . $ex->getMessage()); } return $addresses; }