This relates to gmap_taxonomy.module

Steps to reproduce:

  • Install gmap 7.x-2.x dev and enable gmap, gmap_taxonomy, views
  • Create a taxonomy that enables multiple terms and add two terms to it. Set a different marker for the two terms
  • Add a node and select both tags for this node.

Error displayed:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8' for key 'PRIMARY': INSERT INTO {gmap_taxonomy_node} (nid, tid, marker) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 8 [:db_insert_placeholder_1] => 3 [:db_insert_placeholder_2] => purple ) in gmap_taxonomy_node_update() (line 190 of /var/www/xxx/sites/all/modules/gmap/gmap_taxonomy.module).

The issue is in gmap_taxonomy.module, where it tries to add a row in gmap_taxonomy_node for each tag.

 178     // Otherwise loop through and set marker for term, if term has marker
 179     foreach ($terms as $term) {

Not sure if the desired behavior is to store/display one marker per node or multiple, but right now the table schema is made for one and the code is made for the other.

Comments

GolDRoger’s picture

Same problem happens to me, any idea how to solve this?

amcc’s picture

same issue for me - have a taxonomy on a node that enables multiple selection as above

bewhy’s picture

I'm experiencing this problem. My solution was to only add markers for 1st level terms, not 2nd level terms (I had to go into the database and delete the unwanted ones manually). I know that this assumes that the taxonomy has a hierarchy and only some terms having a marker type.

If you want multiple tags for multiple markers, what decides which markers to display? AFter all, there's only one marker on the map per location.

I think the middle-road is for the code to select the taxonomy term with the 'lightest weight', assuming that taxonomy terms have weights in the first place. Another option (if you have a hierarchy) is that you only add the markers for taxonomy terms that have no parent.

forgot to put in my deets:
gmap 7.x-2.8
location 7.x-3.0-rc6

FuXXz’s picture

Issue summary: View changes

why the errors are ignored for years?

dan1eln1el5en’s picture

also interested in a fix for this.

cossme’s picture

StatusFileSize
new447 bytes

here is quick patch that solves the issue: add a break in line 209 of gmap_taxonomy.module file

      // Insert to gmap_taxonomy table
      db_insert('gmap_taxonomy_node')
        ->fields(array(
          'nid' => $node->nid,
          'tid' => $term['tid'],
          'marker' => $gmap_taxonomy_markers[$term['tid']],
        ))
        ->execute();

      // @20150324 by cossme
      // because only 1 term marker per node is allowed (db schema constraint) break here
      // @see https://www.drupal.org/node/2043673
      break;
    }
}

[edit] sorry, I was to fast: in order to get this to work you also need to drop the column "vid" in gmap_taxonomy_node - that column and the fact that it was removed from the schema without actually dropping it from the table is the true cause of the error. [/edit]

thomas.frobieter’s picture

Patch #6 works great for me!

anybody’s picture

-- unwanted double posting TO BE REMOVED --

anybody’s picture

Status: Active » Reviewed & tested by the community

I can confirm the patch works and is logically okay. Please remove the unnecessary comments from the patch when applying it against the dev release.

This should be fixed ASAP, because the problem leads to a database error. Thanks a lot for your good work. Setting this RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: gmap_taxonomy.module.patch, failed testing.

anpolimus’s picture

Assigned: Unassigned » anpolimus

If we want to fix this problem, we have to add delta field to the mysql table.
@podarok - can I do this here?

podarok’s picture

Category: Bug report » Feature request

@anpolimus this sounds like feature request, not a bug report

anybody’s picture

Status: Needs work » Reviewed & tested by the community

The issue is still open and leads to errors... please help! It's RTBC!

podarok’s picture

Status: Reviewed & tested by the community » Needs work

Patch can't be applied. Needs reroll

anybody’s picture

Status: Needs work » Needs review
StatusFileSize
new447 bytes

Reroll

Status: Needs review » Needs work

The last submitted patch, 15: gmap_taxonomy.module_15.patch, failed testing.

anybody’s picture

Status: Needs work » Needs review
StatusFileSize
new442 bytes

Reroll 2

Status: Needs review » Needs work

The last submitted patch, 17: gmap_taxonomy.module_17.patch, failed testing.

anybody’s picture

Sorry. Here's the hopefully final one that works.

anybody’s picture

anybody’s picture

Status: Needs work » Needs review
anybody’s picture

Status: Needs review » Reviewed & tested by the community

#19 is RTBC.
@Module maintainer: Please apply and add to the next stable release. This bug is really disturbing.

podarok’s picture

Assigned: anpolimus » Unassigned
Status: Reviewed & tested by the community » Fixed

#19 is merged
Thanks

podarok’s picture

  • podarok committed 6753bf3 on 7.x-2.x authored by Anybody
    Issue #2043673 by Anybody, cossme: DB error when adding nodes with...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

infopicard’s picture

I would like to reopen this issue - because I use the current gmap version 7.x-2.11 with has included the patch mentioned here in this threat.

but if I edit an existing node and klick on save, I get the same error message :-(
I have only one marker related to on taxonomy term and only one taxonomy entry related to a node. ok, there are several vocabulary connected to the content type but only one taxonomy is relevant for the marker type.

my site is a migrated D6 site - the D6 site works without problems.
I use GMAP and LOCATION modules to store geodata to Node Locations in D7 because of migration from D6.

I have several problems to make the migration work under D7 (unfortunately not D8 because of missing a lot of Modules in D8, especially GMAP and LOCATION :-( )

I need urgent help on this issue - anybody an idea?