A global flag creates multiple flagging entities randomly

Created on 16 November 2023, about 1 year ago

Problem/Motivation

We have a global flag "editor assignment" with a reference field to a user entity. Someone with the right permissions to use the flag can flag a node and select an assigned user (reference field). We noticed that some flagged nodes are repeated in a view.

Since we're using a relationship between the node and flagging to pull the assigned editor user name from the flagging reference field, we investigated the reason behind this in flagging context. Turns out in some random and impossible to properly reproduce cases more than one flagging entry is created with the same values, with a second to three seconds within each other. Here is sample result of a query from the database:

SELECT flagging.uid, flagging.global, from_unixtime(flagging.created) as created_utc, flagging.flag_id, flagging__field_assigned_editor.field_assigned_editor_target_id FROM flagging  LEFT JOIN flagging__field_assigned_editor ON flagging__field_assigned_editor.entity_id = flagging.id  WHERE flagging.entity_id = 13019  ORDER BY flagging.created;
+-----+--------+---------------------+-------------------+---------------------------------+
| uid | global | created_utc         | flag_id           | field_assigned_editor_target_id |
+-----+--------+---------------------+-------------------+---------------------------------+
|  23 |      1 | 2023-08-30 12:48:26 | editor_assignment |                              23 |
|  23 |      1 | 2023-08-30 12:48:29 | editor_assignment |                              23 |
|  23 |      1 | 2023-08-30 12:48:30 | editor_assignment |                              23 |
|  23 |      1 | 2023-08-30 12:48:31 | editor_assignment |                              23 |
+-----+--------+---------------------+-------------------+---------------------------------+

You can see that when uid 23 flagged the nid 13019 and chose himself as the referenced uid in assigned editor field, 4 flagging entities were created within 5 seconds.

Steps to reproduce

  • Create a global flag for nodes
  • Choose article from flaggable types
  • Choose field entry form as the link type
  • Choose dialog for form behavior
  • Choose display link as field
  • Choose display link on full content view mode
  • Add an entity reference field to user entities
  • Go to article content type, manage display, and make sure that the flag field is enabled in full view mode
  • Open any article in full view and flag it, choosing a user in the reference field

As I mentioned in problem, this occurs randomly and we cannot fully reproduce it or make sure it will happen exactly like that every time. The most number of flaggings created was 4, the least and most common is 2. Out if 564 flagged nodes, 37 had this issue.

Proposed resolution

If you could guide me to what I need to do catch this when it happens to be able to investigate it further and find a solution.

🐛 Bug report
Status

Active

Version

4.0

Component

Flag core

Created by

🇪🇬Egypt shadysamir

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

Comments & Activities

Production build 0.71.5 2024