Duplicate entry for key 'fid_entity_id_uid_sid': INSERT INTO {flagging}

Created on 14 July 2015, about 10 years ago
Updated 19 August 2025, 6 days ago

I use a rule to flag recently viewed nodes to show it in a block. I dont know but i guess my rule is not perfect because somtimes a user cause following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-287-1-0' for key 'fid_entity_id_uid_sid': INSERT INTO {flagging} (fid, entity_type, entity_id, uid, sid, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => 287 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 1436869178 ) in drupal_write_record() (Zeile 7316 von ***/includes/common.inc).

Here is my rule:

{ "rules_zuletzt_angesehene_nodes_flaggen" : {
    "LABEL" : "Zuletzt angesehene Nodes flaggen",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "node_view" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "node" ],
          "type" : "node",
          "bundle" : { "value" : {
              "artikel" : "artikel",
              "haus" : "haus",
              "route" : "route",
              "veranstaltung" : "veranstaltung"
            }
          }
        }
      },
      { "data_is" : { "data" : [ "view-mode" ], "value" : "body" } }
    ],
    "DO" : [
      { "flag_flagnode" : {
          "flag" : "viewed",
          "node" : [ "node" ],
          "flagging_user" : [ "site:current-user" ],
          "permission_check" : "1"
        }
      }
    ]
  }
}
🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Flag core

Created by

🇩🇪Germany Schnitzer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024