For not logged in users, site throw this error:

The website encountered an unexpected error. Please try again later.
LogicException: An anonymous user must be identifed by session ID. in Drupal\flag\FlagService->getAllEntityFlaggings() (line 194 of modules/flag/src/FlagService.php).

Drupal\flag\FlagService->getAllEntityFlaggings(Object, Object) (Line: 24)
message_subscribe_email_flag_action_access('flag', Object, Object, Object)
call_user_func_array('message_subscribe_email_flag_action_access', Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler->invokeAll('flag_action_access', Array) (Line: 175)
Drupal\flag\FlagType\FlagTypeBase->actionAccess('flag', Object, Object, Object) (Line: 314)
Drupal\flag\Plugin\Flag\EntityFlagType->actionAccess('flag', Object, Object, Object) (Line: 145)
Drupal\flag\Plugin\Flag\UserFlagType->actionAccess('flag', Object, Object, Object) (Line: 355)
Drupal\flag\Entity\Flag->actionAccess('flag', Object, Object) (Line: 98)
Drupal\flag\ActionLink\ActionLinkTypeBase->getAsFlagLink(Object, Object) (Line: 23)
Drupal\flag\Plugin\ActionLink\AJAXactionLink->getAsFlagLink(Object, Object) (Line: 48)
Drupal\flag\FlagLinkBuilder->build('user', '1', 'email_user')
call_user_func_array(Array, Array) (Line: 356)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 151)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 152)
Drupal\Core\Render\Renderer->renderPlain(Array) (Line: 166)
Drupal\Core\Render\Renderer->renderPlaceholder('callback=flag.link_builder%3Abuild&args[0]=user&args[1]=1&args[2]=email_user&token=GCdGR5FCVqLIzAYH2-ME7D7hVeeb5zSHsC4ULIdn5iY', Array) (Line: 698)
Drupal\big_pipe\Render\BigPipe->renderPlaceholder('callback=flag.link_builder%3Abuild&args[0]=user&args[1]=1&args[2]=email_user&token=GCdGR5FCVqLIzAYH2-ME7D7hVeeb5zSHsC4ULIdn5iY', Array) (Line: 552)
Drupal\big_pipe\Render\BigPipe->sendPlaceholders(Array, Array, Object) (Line: 305)
Drupal\big_pipe\Render\BigPipe->sendContent(Object) (Line: 112)
Drupal\big_pipe\Render\BigPipeResponse->sendContent() (Line: 374)
Symfony\Component\HttpFoundation\Response->send() (Line: 20)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

admirernepali created an issue. See original summary.

joachim’s picture

Category: Bug report » Support request
Priority: Major » Normal
Status: Needs work » Active
Issue tags: -bug

The signature of getAllEntityFlaggings() has changed in the latest alpha.

(BTW there is no point in tagging an issue with 'bug', since the category field already tells you that!)

admirernepali’s picture

It still seems not fixed. I still get the same error. Error happens for anonymous users only.

LogicException: An anonymous user must be identifed by session ID. in Drupal\flag\FlagService->getAllEntityFlaggings() (line 194 of /modules/flag/src/FlagService.php).

joachim’s picture

You are calling that method incorrectly.

admirernepali’s picture

I haven't changed or called any function. I just installed fresh module and while not logged it, getting that exception.

How do I suppose to call that method?

joachim’s picture

Status: Active » Fixed

You installed the new version of the module, but because the module is still in alpha, the API has changed.

message_subscribe_email_flag_action_access() is calling it wrong. It's not part of Flag. You need to change that code, or if it's another contrib module, get that module's maintainer to change it.

Status: Fixed » Closed (fixed)

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

admirernepali’s picture

Thanks for update.

When I disable that module, on cron run I get this error:

Type cron
Date Sunday, June 18, 2017 - 08:04
User Anonymous (not verified)
Location http://domain.com/admin/config/system/cron
Referrer http://domain.com/admin/config/system/cron
Message LogicException: An anonymous user must be identifed by session ID. in Drupal\flag\FlagService->getAllEntityFlaggings() (line 194 of /Applications/XAMPP/xamppfiles/htdocs/domain.ct/modules/flag/src/FlagService.php).
Severity Error
Hostname 127.0.0.1

Any idea about this?

This error is now not showing. Not sure what change I made.

dpi’s picture

A related issue has been created for message_subscribe: https://github.com/Gizra/message_subscribe/issues/102

drupaleze’s picture

This solved mine (at least the error is gone).

I simply located the Flag module and edited the file modules/flag/src/FlagService.php

On line 193 up to line 195, I commented those out

i.e.

/** DISABLED {
*throw new \LogicException('An anonymous user must be identifed by session ID.');
} */

For now, I don't have any issues, although I'm not really sure of the implications of this action.

oriol_e9g’s picture

eahonet’s picture

For me it was message_subscribe_email module and the patch from here fixed:
https://www.drupal.org/project/message_subscribe/issues/2928789

zanvidmar’s picture

Version: 8.x-4.0-alpha2 » 8.x-4.x-dev
Category: Support request » Bug report
FileSize
464 bytes

In my case. The issue was that $account was not null but $session_id was.
That being said. Here is the patch that check if both variables (account and session_id) are null

turtletrail’s picture

#13 did the trick for me.
thanks!

turtletrail’s picture

updating my last reply, #13 should not be applied. See problem description: https://www.drupal.org/project/flag/issues/3075108#comment-13224836

MartinMa’s picture

Hm,

I get it on /user/register and not at other pages (as it seem now for me) ...

I had the whole message stack installed too, so maybee there is a relation.

After uninstalling Message Digest UI:

Error: Call to undefined function message_digest_allowed_values_callback() in options_allowed_values() (Line 89 in /core/modules/options/options.module)

After
Message Subcribe Email
Message Subscribe UI
Message Subscribe

same Error as above

After unistalling Message Digest:

Error: Call to a member function getPath() on null in Drupal\config_translation\ConfigNamesMapper->getOverviewRoute() (Line 247 in /core/modules/config_translation/src/ConfigNamesMapper.php)

and for anonymous users:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "message_digest_interval" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (Line 150 in /core/lib/Drupal/Core/Entity/EntityTypeManager.php).

/user/register still doesnt work!

MartinMa’s picture

Priority: Normal » Major
MartinMa’s picture

I wonder how this issue can be closed if it is not fixed!

If new users cant register, its major for me!

MartinMa’s picture

Followed instruction of https://www.drupal.org/project/message_digest/issues/3095573 and removed field.storage.user.message_digest and also field.storage.user.message_subscribe_email. Register still doesnt work, same error message related to message module ...

zanvidmar’s picture

@turtletrail got it right patch #13 should not be used. The problem in first place in my case wast that anonymous users should not have acces to content where flag is used. I fix this with redirect to login path.

zanvidmar’s picture

Janner’s picture

I encountered the same problem on a test D8 installation.

I deleted the Message Subscribe module's flags for term and user (so, just leaving its content flag), and this *appears* to have resolved the problem with the registration page.

Fortunately for me, I only need the content flag.

Sharing just in case somebody else has the same use case.

hansrossel’s picture

Project: Flag » Message Subscribe
Version: 8.x-4.x-dev » 8.x-1.x-dev
Component: Flag core » Code

Moving this issue to the right project.

This patch is needed to fix it:
https://github.com/hdpe/message_subscribe/commit/9ca5e6082640b088087ae04...

perfectcu.be’s picture

Here's @hansrossel's patch in cweagans/composer-patches consumable form. Note that I applied his patch to the 1.1 version, not 8.x-1.x-dev as originally specified by @hansrossel.

New to cweagans/composer-patches?
Add something like this to your composer.json:

{
  "extra": {
    "patches": {
      "drupal/message_subscribe":{
        "LogicException: An anonymous user must be identifed by session ID, https://www.drupal.org/project/message_subscribe/issues/2880521#comment-14186786":"https://www.drupal.org/files/issues/2021-10-03/message_subscribe-1.1.0--2880521-24--anonymous-user-must-be-identifed-by-session-id_flag-compatibility-issue.patch"
      }
    }
  }
}
DrupalBubb’s picture

Patch #24 works. Maintainers, please change the status to something else.

SocialNicheGuru’s picture

apaderno’s picture

Title: LogicException: An anonymous user must be identifed by session ID. » "LogicException: An anonymous user must be identifed by session ID."
Version: 8.x-1.1 » 8.x-1.x-dev

This issue has been moved, but since it's closed, it won't probably be noticed. (I just found it because I was looking at the recently posted comments.)

It's probably better to open a new issue with the details useful to the maintainers of this project.

apaderno’s picture

Status: Closed (fixed) » Closed (duplicate)
Related issues: -#3075108: Working with another user flags

(Actually, as comment #26 says, there is already an issue opened for this.)