Duplicate entry '6' for key 1 query: INSERT INTO fivestar_comment (cid, vote_id, value, tag) VALUES (6, 20, 100, 'vote') in sites/default/modules/fivestar/fivestar_comment.module on line 229.
when displaying votes on comments, only one tag is displayed ok, the other is empty as the vote didnt save in the fivestar comments table per error above
to fix it, patch fivestar/fivestar_comment.install with the below & run update.php
basically ive switched the primary key and the index, as cid will not be unique when using tags, im also sure this should be changed better, but im not an sql expert
--- fivestar/fivestar_comment.install~ 2010-05-06 11:38:25.000000000 +0000
+++ fivestar/fivestar_comment.install 2010-05-06 11:38:25.000000000 +0000
@@ -9,14 +9,14 @@
function fivestar_comment_schema() {
$schema['fivestar_comment'] = array(
'fields' => array(
- 'cid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+ 'cid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
'vote_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'value' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'),
),
- 'primary key' => array('cid'),
+ 'primary key' => array('vote_id'),
'indexes' => array(
- 'vote_id' => array('vote_id'),
+ 'cid' => array('cid'),
),
);
return $schema;
@@ -62,3 +62,20 @@ function fivestar_comment_update_6200()
return $ret;
}
+
+/**
+ * Fix primary key for fivestar_comment table when using tags.
+ */
+function fivestar_comment_update_6201() {
+ $ret = array();
+
+ db_change_field($ret, 'fivestar_comment', 'cid', 'cid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE));
+
+ db_drop_index($ret, 'fivestar_comment', 'vote_id');
+ db_drop_primary_key($ret, 'fivestar_comment');
+
+ db_add_index($ret, 'fivestar_comment', 'cid', array('cid'));
+ db_add_primary_key($ret, 'fivestar_comment', array('vote_id'));
+
+ return $ret;
+}
Comments
Comment #1
grasmash commentedI've run into the same issue. Applying patch-- I'll add more info if I run into any snags. Thanks.
Comment #2
whiteph commentedWe can no longer support the Drupal 6 version of Fivestar. It is in security maintenance mode only. When the Drupal 8 version of Fivestar is released, the Drupal 6 version will be officially deprecated.
Comment #3
whiteph commentedSee Help testing Drupal 6 patches.