Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!4381
Issue
#3374446
: Block access is checked even if the block's region is never rendered
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Open
Issue
#3374446
: Block access is checked even if the block's region is never rendered
issue/drupal-3374446:3374446-block-access-is
into
11.x
Overview
0
Commits
2
Pipelines
2
Changes
2
Open
Issue #3374446: Block access is checked even if the block's region is never rendered
Pierre Rudloff
requested to merge
issue/drupal-3374446:3374446-block-access-is
into
11.x
Jul 13, 2023
Overview
0
Commits
2
Pipelines
2
Changes
2
0
0
Merge request reports
Compare
11.x
version 3
0bf6aaf6
5 months ago
version 2
3bdaf7ec
5 months ago
version 1
3bdaf7ec
Jul 13, 2023
11.x (HEAD)
and
latest version
latest version
e253311e
2 commits,
5 months ago
version 3
0bf6aaf6
1 commit,
5 months ago
version 2
3bdaf7ec
149 commits,
5 months ago
version 1
3bdaf7ec
1 commit,
Jul 13, 2023
2 files
+
48
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
core/modules/block/src/BlockRepository.php
+
13
−
11
View file @ b8e291fd
Edit in single-file editor
Open in Web IDE
Show full file
@@ -59,19 +59,21 @@ public function getVisibleBlocksPerRegion(array &$cacheable_metadata = []) {
$full
=
[];
foreach
(
$this
->
blockStorage
->
loadByProperties
([
'theme'
=>
$active_theme
->
getName
()])
as
$block_id
=>
$block
)
{
/** @var \Drupal\block\BlockInterface $block */
$access
=
$block
->
access
(
'view'
,
NULL
,
TRUE
);
$region
=
$block
->
getRegion
();
if
(
!
isset
(
$cacheable_metadata
[
$region
]))
{
$cacheable_metadata
[
$region
]
=
CacheableMetadata
::
createFromObject
(
$access
);
}
else
{
$cacheable_metadata
[
$region
]
=
$cacheable_metadata
[
$region
]
->
merge
(
CacheableMetadata
::
createFromObject
(
$access
));
}
if
(
in_array
(
$region
,
array_keys
(
$empty
)))
{
/** @var \Drupal\block\BlockInterface $block */
$access
=
$block
->
access
(
'view'
,
NULL
,
TRUE
);
if
(
!
isset
(
$cacheable_metadata
[
$region
]))
{
$cacheable_metadata
[
$region
]
=
CacheableMetadata
::
createFromObject
(
$access
);
}
else
{
$cacheable_metadata
[
$region
]
=
$cacheable_metadata
[
$region
]
->
merge
(
CacheableMetadata
::
createFromObject
(
$access
));
}
// Set the contexts on the block before checking access.
if
(
$access
->
isAllowed
())
{
$full
[
$region
][
$block_id
]
=
$block
;
// Set the contexts on the block before checking access.
if
(
$access
->
isAllowed
())
{
$full
[
$region
][
$block_id
]
=
$block
;
}
}
}
Loading