From: Raphaël Barrois Date: Sun, 5 Sep 2010 23:02:12 +0000 (+0200) Subject: Hotfix for foreign keys in profile_address edition (Closes #1228) X-Git-Tag: xorg/1.0.1~221 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8d1e0ab3b5d56783bb136e52a94e86440ad9b1b1;p=platal.git Hotfix for foreign keys in profile_address edition (Closes #1228) 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 --- 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,