From dd9d7b83a8ff3f3c47f01d3648f540fb431f3c85 Mon Sep 17 00:00:00 2001
From: Eileen McNaughton <eileen@fuzion.co.nz>
Date: Tue, 21 Jan 2014 00:55:20 +1300
Subject: [PATCH] fix failing profile api test by preventing double-adding of
 same alias

---
 api/v3/Profile.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/api/v3/Profile.php b/api/v3/Profile.php
index 099aa01ac1..4b7c479b2b 100644
--- a/api/v3/Profile.php
+++ b/api/v3/Profile.php
@@ -580,8 +580,10 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour =
         if(isset($profileFields[$profileID][$entityfield])) {
           unset($profileFields[$profileID][$entityfield]);
         }
-        // we will make the mixed case version (e.g. of 'Primary') an alias
-        $profileFields[$profileID][$fieldName]['api.aliases'][] = $entityfield;
+        if(!in_array($entityfield, $profileFields[$profileID][$fieldName]['api.aliases'])) {
+          // we will make the mixed case version (e.g. of 'Primary') an alias
+          $profileFields[$profileID][$fieldName]['api.aliases'][] = $entityfield;
+        }
       }
       /**
        * putting this on hold -this would cause the api to set the default - but could have unexpected behaviour
-- 
GitLab