[fix] #433 -- IPTC locations were being duplicated with null states.

This commit is contained in:
Solomon Peachy 2010-06-17 11:01:44 -04:00
parent 22d8e4092d
commit 0ab352e7f1
2 changed files with 20 additions and 9 deletions

View File

@ -28,7 +28,8 @@ For further information about Photo Organizer, see its web site at:
[fix] Fix memcache not being cleared when the folder/album name was changed.
[misc] Get rid of warning when running under php 4.3.x
[fix] Switch to the 'memcached' extension (instead of 'memcache')
[fix] Newer versions of exiftool changed tagnames slightly.
[fix] Newer versions of exiftool changed tagnames slightly. [#432]
[fix] Fix duplicate IPTC location creation. [#433]
2.37-rc2 (October 13, 2009)

View File

@ -44,15 +44,26 @@ function convert_iptc2sql_timestamp($date, $time) {
}
function convert_iptc_location($database, $user_id, $place, $city, $state, $country) {
$froms = "";
if ($state != '' && $state != 'null') {
$froms .= ", state";
$where .= " and state.value ILIKE '%$state%' and location.state = state.identifier ";
} else {
$where .= ' and location.state is null ';
}
if ($country != '' && $country != 'null') {
$froms .= ", country";
$where .= " and country.value ILIKE '%$country%' and location.country = country.identifier ";
} else {
$where .= ' and location.country is null ';
}
$location = pg_fetch_row(pg_query($database, "
select location.identifier
from location, country, state
from location $froms
where location.city ILIKE '%$city%'
and state.value ILIKE '%$state%'
and location.state = state.identifier
and country.value ILIKE '%$country%'
and location.place ILIKE '%$place%'
and location.country = country.identifier"));
$where "));
/* unlike elsewhere we look for exact matches */
if ($location) {
@ -64,7 +75,7 @@ function convert_iptc_location($database, $user_id, $place, $city, $state, $coun
/* check for existing state/region */
/* if not found create one */
if (($state) && ($state != 'null')) {
if (($state) && ($state != 'null') && ($state != '')) {
$state_id = pg_fetch_row(pg_query($database, "select identifier from
state where value ILIKE '%$state%'"));
if (!$state_id) {
@ -79,7 +90,7 @@ state where value ILIKE '%$state%'"));
/* check for existing country */
/* if not found create one - you never know these days */
if (($country) && ($country != 'null')) {
if (($country) && ($country != 'null') && ($country != '')) {
$country_id = pg_fetch_row(pg_query($database, "select identifier from country where value ILIKE '%$country%'"));
if (!$country_id) {
$country_id = pg_fetch_row(pg_query($database, "select nextval('country_id_sequence')"));
@ -88,7 +99,6 @@ state where value ILIKE '%$state%'"));
return "0";
}
pg_query($database, "insert into country (identifier, value) values ($country_id[0], '$country')");
// print "insert into country (identifier, value) values ($country_id[0], '$country'";
}
}