Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
message_subscribe
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
message_subscribe
Merge requests
!8
Issue
#3388551
: "An anonymous user must be identified by session ID" crash on Drupal 10
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3388551
: "An anonymous user must be identified by session ID" crash on Drupal 10
issue/message_subscribe-3388551:3388551-an-anonymous-user
into
8.x-1.x
Overview
0
Commits
3
Pipelines
6
Changes
1
Merged
codebymikey
requested to merge
issue/message_subscribe-3388551:3388551-an-anonymous-user
into
8.x-1.x
1 year ago
Overview
0
Commits
3
Pipelines
6
Changes
1
Expand
Closes
#3388551
0
0
Merge request reports
Compare
8.x-1.x
version 6
e8bb1188
3 months ago
version 5
df40b9b4
1 year ago
version 4
c4c7159d
1 year ago
version 3
037ac055
1 year ago
version 2
a91ffff4
1 year ago
version 1
b5f84e14
1 year ago
8.x-1.x (base)
and
latest version
latest version
e8bb1188
3 commits,
3 months ago
version 6
e8bb1188
3 commits,
3 months ago
version 5
df40b9b4
2 commits,
1 year ago
version 4
c4c7159d
4 commits,
1 year ago
version 3
037ac055
3 commits,
1 year ago
version 2
a91ffff4
2 commits,
1 year ago
version 1
b5f84e14
1 commit,
1 year ago
1 file
+
21
−
12
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
message_subscribe_email/message_subscribe_email.module
+
21
−
12
Options
@@ -18,27 +18,36 @@ function message_subscribe_email_flag_action_access($action, FlagInterface $flag
// The 'unflag' action is always allowed here, so only check 'flag'.
$prefix
=
\Drupal
::
config
(
'message_subscribe_email.settings'
)
->
get
(
'flag_prefix'
)
.
'_'
;
if
(
$action
===
'flag'
&&
$flaggable
&&
$flaggable
->
id
()
&&
strpos
(
$flag
->
id
(),
$prefix
)
===
0
)
{
/** @var \Drupal\flag\FlagServiceInterface $flag_service */
$flag_service
=
\Drupal
::
service
(
'flag'
);
$request
=
\Drupal
::
request
();
$sid
=
$request
->
hasSession
()
?
$request
->
getSession
()
->
get
Id
(
)
:
NULL
;
$sid
=
$request
->
hasSession
()
?
$request
->
getSession
()
->
get
(
'flag.session_id'
)
:
NULL
;
// If the user is anonymous, force a session and session ID.
// Copied from FlagService::populateFlaggerDefaults() and
// FlagService::ensureSession().
if
(
empty
(
$sid
)
&&
$account
==
NULL
)
{
if
(
empty
(
$sid
)
&&
$account
==
=
NULL
)
{
$account
=
\Drupal
::
currentUser
();
}
if
(
empty
(
$sid
)
&&
$account
->
isAnonymous
())
{
// Ensure something is in $_SESSION, otherwise the session ID will
// not persist.
// @todo Replace this with something cleaner once core provides it.
// See https://www.drupal.org/node/2865991.
$_SESSION
[
'flag'
]
=
TRUE
;
$session
=
\Drupal
::
service
(
'session_manager'
);
$session
->
start
();
$sid
=
$session
->
getId
();
// @todo when https://www.drupal.org/node/2865991 is resolved,
// use force start session API.
if
(
!
$request
->
hasSession
())
{
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
$session
=
\Drupal
::
service
(
'session'
);
$request
->
setSession
(
$session
);
$session
->
start
();
}
$session
=
$request
->
getSession
();
if
(
$session
->
has
(
'flag.session_id'
))
{
$sid
=
$session
->
get
(
'flag.session_id'
);
}
else
{
// Generate a persistent session id.
$sid
=
$flag_service
->
getAnonymousSessionId
();
$session
->
set
(
'flag.session_id'
,
$sid
);
}
}
// Get the other flags on that same content.
Loading