Deleted comments may not be purged from cache, causing Flag errors

Created on 11 July 2019, about 6 years ago
Updated 19 August 2025, 6 days ago

We use the Entitycache module, and noticed the Flag module occasionally generates errors when a comment is deleted.

It seems as though Entitycache has not yet flushed all deleted items, and Flag is referencing it in the get_flagging_record function. This happens when the deleted comment is the first comment on a new page.

The error messages received are as follows. These will be logged until entitycache gets cleared:

Notice: Trying to get property of non-object in flag_entity->applies_to_entity() (line 131 of /sites/all/modules/flag/includes/flag/flag_entity.inc).

Notice: Trying to get property of non-object in flag_comment->get_flagging_record() (line 85 of /sites/all/modules/flag/includes/flag/flag_comment.inc).

Notice: Trying to get property of non-object in flag_comment->get_flagging_record() (line 102 of /sites/all/modules/flag/includes/flag/flag_comment.inc).

Notice: Trying to get property of non-object in flag_comment->get_flagging_record() (line 144 of /sites/all/modules/flag/includes/flag/flag_comment.inc).

I've created a patch to check for an empty entity, and return NULL or FALSE if it is.

Maybe the thought would be this issue should be handled in Entitycache, and technically it is... there is a support module called Entitycache Flush that can be used to more actively flush entitycache content.

However, the module is not extensively used, and I think it's acceptable and good practice to check for the existence of object content anyway.

Review the attached patch and let me know your thoughts. Thanks.

πŸ› Bug report
Status

Closed: outdated

Version

3.0

Component

Flag core

Created by

πŸ‡ΊπŸ‡ΈUnited States ron_s

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