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

Command icon 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

gillesv created an issue. See original summary.

gillesv’s picture

Version: 8.x-4.0-beta2 » 8.x-4.x-dev
blecheimer’s picture

Hello this patch solved my problems (described like above) please consider to apply this patch in next release

deaom made their first commit to this issue’s fork.

deaom’s picture

Version: 8.x-4.x-dev » 5.x-dev
Status: Active » Needs review

Could 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.

ivnish changed the visibility of the branch 3213165-personal-anonymous-flagging to hidden.

  • ivnish committed b51daa23 on 5.x authored by deaom
    fix: #3213165 Personal anonymous flagging + "Field entry form" - doesn't...
ivnish’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.