From 8d1e0ab3b5d56783bb136e52a94e86440ad9b1b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 6 Sep 2010 01:02:12 +0200 Subject: [PATCH] Hotfix for foreign keys in profile_address edition (Closes #1228) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some foreign_key-referenced fields where empty (''), which meant inserting '' into the DB instead of NULL. There might be other similar issues with other foreign keys. Signed-off-by: Raphaël Barrois --- modules/profile/addresses.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 9722476..6fe6f75 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -94,6 +94,15 @@ class ProfileSettingAddress extends ProfileSettingGeocoding Geocoder::getAreaId($address, "administrativeArea"); Geocoder::getAreaId($address, "subAdministrativeArea"); Geocoder::getAreaId($address, "locality"); + + // Cleanup foreign keys + $foreign_keys = array('localityId', 'subAdministrativeAreaId', 'administrativeAreaId', 'countryId'); + foreach ($foreign_keys as $key) { + if ($address[$key] == '') { + $address[$key] = null; + } + } + XDB::execute("INSERT INTO profile_addresses (pid, type, id, flags, accuracy, text, postalText, postalCode, localityId, subAdministrativeAreaId, administrativeAreaId, -- 2.1.4