MantisBT - Piwigo
View Issue Details
0000559Piwigometadatapublic2006.10.11 16:052012.02.10 14:57
dppiseb 
plg 
normalmajoralways
closedfixed 
LinuxRedHatFedora Core 4
1.6.1 
2.3.32.3.3 
Safari
4.1.11
5.0.4
Apache 2.0.54
0000559: duplicate insert on tags when synchronizing metadata
The following message appears when updating metadata from admin.php?page=site_update&site=1 or admin.php?page=picture_modify :
INSERT INTO phpwebgallery_image_tag
   (image_id,tag_id)
    VALUES
   ('1493','522')
   ,('1493','515')
[...]
   ,('1493','524')
   ,('1493','11')
;
[mysql error 1062] Duplicate entry '1493-408' for key 1

updating metadata from admin.php?page=site_update&site=1 or admin.php?page=picture_modify
No tags attached.
Issue History
2006.10.11 16:05dppisebNew Issue
2006.10.11 16:05dppisebbrowser => Safari
2006.10.11 16:05dppisebMySQL version => 4.1.11
2006.10.11 16:05dppisebPHP version => 5.0.4
2006.10.11 16:05dppisebWeb server => Apache 2.0.54
2006.10.12 09:28plgNote Added: 0001462
2006.10.12 09:28plgAssigned To => plg
2006.10.12 09:28plgStatusnew => assigned
2006.10.12 13:10dppisebNote Added: 0001465
2006.10.16 23:29plgSummaryMySQL error message when updating metadata => duplicate insert on tags when synchronizing metadata
2006.10.16 23:48plgNote Added: 0001475
2012.01.10 14:00plgNote Added: 0005911
2012.01.10 14:00plgTarget Version => 2.3.3
2012.02.10 14:55svnCheckin
2012.02.10 14:55svnNote Added: 0006015
2012.02.10 14:57svnCheckin
2012.02.10 14:57svnNote Added: 0006016
2012.02.10 14:57plgStatusassigned => closed
2012.02.10 14:57plgResolutionopen => fixed
2012.02.10 14:57plgFixed in Version => 2.3.3

Notes
(0001462)
plg   
2006.10.12 09:28   
Quick correction: in admin/include/functions.php, release 1.6.1, line 1805 in set_tags_of function, replace:

foreach ($tag_ids as $tag_id)

by

foreach (array_unique($tag_ids) as $tag_id)


As a reminder for me: apply this modification to the set_tags_of and replace set_tags by set_tags_of everywhere.
(0001465)
dppiseb   
2006.10.12 13:10   
This fixes the main update bug, but now I get a new error message :
INSERT INTO phpwebgallery_tags
  (name,url_name)
   VALUES
  (NULL,NULL)
;
[mysql error 1048] Column 'name' cannot be null
(0001475)
plg   
2006.10.16 23:48   
> INSERT INTO phpwebgallery_tags
> (name,url_name)
> VALUES
> (NULL,NULL)
> ;

After a code investigation and some tests, it seems that your IPTC value mapped to tags sometimes contains "foo,,bar". To avoid any "empty" tag, in admin/include/functions_metadata.php, function get_sync_iptc_data, release 1.6.1, line 55, after:

  $iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']);

insert:

  $iptc['keywords'] = preg_replace('/,+/', ',', $iptc['keywords']);
(0005911)
plg   
2012.01.10 14:00   
http://piwigo.org/forum/viewtopic.php?pid=127013#p127013 [^]
(0006015)
svn   
2012.02.10 14:55   
[Subversion] r13080 by plg on branch 2.3

-----[Subversion commit log]----------------------------------------------------
bug 559 fixed: avoid duplicate insert on tags when synchronizing metadata if
the IPTC keywords contains repeated separators like "tag1,,tag2".
(0006016)
svn   
2012.02.10 14:57   
[Subversion] r13081 by plg on trunk

-----[Subversion commit log]----------------------------------------------------
merge r13080 from branch 2.3 to trunk

bug 559 fixed: avoid duplicate insert on tags when synchronizing metadata if
the IPTC keywords contains repeated separators like "tag1,,tag2".