From d8476774cb9d28a867f123c1ca6aec508f4ac0fd Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 14 Oct 2010 13:57:01 +0200 Subject: [PATCH] Fix address<->phone association on profile. Signed-off-by: Florent Bruneau --- include/profilefields.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index e841c16..cc8b73b 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -539,8 +539,13 @@ class ProfileAddresses extends ProfileField { $p = $phones->get(Profile::PHONE_LINK_ADDRESS | Profile::PHONE_TYPE_ANY); foreach ($p as $phone) { - if ($phone->linkType() == Phone::LINK_ADDRESS && array_key_exists($phone->linkId(), $this->addresses)) { - $this->addresses[$phone->linkId()]->addPhone($phone); + /* We must iterate on the addresses because id is not uniq thus, + * $this->addresse[$phone->linkId()] is invalid. + */ + foreach ($this->addresses as $address) { + if ($address->type == Address::LINK_PROFILE && $address->id == $phone->linkId()) { + $address->addPhone($phone); + } } } } -- 2.1.4