Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3504114
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
drupal-3504114
Commits
bd40e4e2
Commit
bd40e4e2
authored
4 months ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Move user.roles:authenticated cache context around.
parent
446106f6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/node/src/NodeAccessControlHandler.php
+8
-1
8 additions, 1 deletion
core/modules/node/src/NodeAccessControlHandler.php
core/modules/node/src/NodeGrantDatabaseStorage.php
+0
-1
0 additions, 1 deletion
core/modules/node/src/NodeGrantDatabaseStorage.php
with
8 additions
and
2 deletions
core/modules/node/src/NodeAccessControlHandler.php
+
8
−
1
View file @
bd40e4e2
...
...
@@ -207,6 +207,14 @@ protected function checkViewAccess(NodeInterface $node, AccountInterface $accoun
// we need to add the node as a cacheable dependency.
$cacheability
->
addCacheableDependency
(
$node
);
// Due to the check below, it is not possible to rely only on account
// permissions to determine whether the 'view own unpublished content'
// permission can be checked, instead we also need to check if the user has
// the authenticated role. Just in case anonymous and authenticated users
// are both granted the 'view own unpublished content' permission and also
// have otherwise identical permissions.
$cacheability
->
addCacheContext
([
'user.roles.authenticated'
]);
if
(
$node
->
isPublished
())
{
return
NULL
;
}
...
...
@@ -216,7 +224,6 @@ protected function checkViewAccess(NodeInterface $node, AccountInterface $accoun
return
NULL
;
}
$cacheability
->
addCacheContexts
([
'user.roles:authenticated'
]);
// The "view own unpublished content" permission must not be granted
// to anonymous users for security reasons.
if
(
!
$account
->
isAuthenticated
())
{
...
...
This diff is collapsed.
Click to expand it.
core/modules/node/src/NodeGrantDatabaseStorage.php
+
0
−
1
View file @
bd40e4e2
...
...
@@ -121,7 +121,6 @@ public function access(NodeInterface $node, $operation, AccountInterface $accoun
// know it for a fact.
$set_cacheability
=
function
(
AccessResult
$access_result
)
use
(
$operation
)
{
$access_result
->
addCacheContexts
([
'user.node_grants:'
.
$operation
]);
$access_result
->
addCacheContexts
([
'user.roles.authenticated'
]);
if
(
$operation
!==
'view'
)
{
$access_result
->
setCacheMaxAge
(
0
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment