Flagging save throws PDO exceptions when flag has fields

Created on 28 July 2015, about 10 years ago
Updated 19 August 2025, 2 months ago

I have a node flag and all configurations are working fine. I have a field created for the flag to track some additional details related to the flag.

I tried using flagging_save() function to grammatically save new flags based on some logic. It shows a error as

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entity_id' cannot be null: INSERT INTO {field_data_message_subscribe_email_freq} (entity_type, entity_id, revision_id, bundle, delta, language, message_subscribe_email_freq_value) 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, :db_insert_placeholder_6); Array
(
[:db_insert_placeholder_0] => flagging
[:db_insert_placeholder_1] =>
[:db_insert_placeholder_2] =>
[:db_insert_placeholder_3] => email_node
[:db_insert_placeholder_4] => 0
[:db_insert_placeholder_5] => und
[:db_insert_placeholder_6] => email
)
in field_sql_storage_field_storage_write()

If the flag don't have the field then it works fine.

Hth,
Sadashiv.

🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Flag core

Created by

🇮🇳India sadashiv

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