Problem/Motivation
When allowing anonymous users to create a personal flag, while using the "Field entry form" link type, the flagging status is not remembered for that user. It seems that the Flag module does not assure that a session has been created when using the "Field entry form", resulting in a session variable that gets destroyed immediately. As soon as the anonymous user refreshes, the flag-link is reset as if the user never used the flag.
Steps to reproduce
- Create flag of type "personal", and link type "Field entry form"
- Allow anonymous users to use this flag (flag and unflag)
- Try flagging an entity using this flag and refreshing the page afterwards
Proposed resolution
The flag module should assure a session has been started when creating a flag via the field entry form. This could maybe be done in the "save" function of "FlaggingForm"?
The "flag" function of FlagService calls a function called "ensureSession" (also part of the FlagService), but the "Field entry form" link type never uses the FlagService, so the "ensureSession" function is never called.
Remaining tasks
- Confirm that this is a bug
- Determine the best way to fix this issue
User interface changes
None
API changes
Unknown
Data model changes
Unknown
Issue fork flag-3213165
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gillesv commentedComment #3
blecheimer commentedHello this patch solved my problems (described like above) please consider to apply this patch in next release
Comment #6
deaom commentedCould confirm the issue is still present in 5.x. The ensureSession function in flag service was made public so it could be used in form entity as well + simple test for anonymous personal flag. Ready for review.
Comment #9
ivnish