Problem/Motivation When deleting a flag that is associated with a flaggable that no longer exists, FlagCountManager will try and pass a NULL item into resetLoadedCounts, which is rejected as a TypeError.
Steps to reproduce Not sure how this cropped up, although I expect it can be reproduced like this:
Create a content type
Create a flag that can be used to flag the content type
Create a content item of the new tyoe
Flag the content item
Delete the content item
Delete the flagging in code; load the flag, call ->delete() on it
Proposed resolution Check whether the flaggable still exists before passing it into resetLoadedCounts().
Remaining tasks Create MR
Review
Commit
User interface changes None
API changes None
Data model changes None