Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
222
Merge Requests
222
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
e16798a8
Commit
e16798a8
authored
Dec 20, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2151457
by Wim Leers, amateescu, msonnabaum: Comment pager breaks the render cache.
parent
aa6d6fb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
core/modules/comment/comment.module
core/modules/comment/comment.module
+20
-0
No files found.
core/modules/comment/comment.module
View file @
e16798a8
...
...
@@ -249,6 +249,9 @@ function comment_field_instance_create(FieldInstanceInterface $instance) {
function
comment_field_instance_update
(
FieldInstanceInterface
$instance
)
{
if
(
$instance
->
getType
()
==
'comment'
)
{
\
Drupal
::
entityManager
()
->
getViewBuilder
(
$instance
->
entity_type
)
->
resetCache
();
// Comment field settings also affects the rendering of *comment* entities,
// not only the *commented* entities.
\
Drupal
::
entityManager
()
->
getViewBuilder
(
'comment'
)
->
resetCache
();
}
}
...
...
@@ -416,6 +419,23 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en
return
$pagenum
;
}
/**
* Implements hook_entity_view_alter().
*/
function
comment_entity_view_alter
(
&
$build
,
EntityInterface
$entity
,
EntityViewDisplayInterface
$display
)
{
// Add the comment page number to the cache key if render caching is enabled.
if
(
isset
(
$build
[
'#cache'
])
&&
isset
(
$build
[
'#cache'
][
'keys'
])
&&
\
Drupal
::
request
()
->
query
->
has
(
'page'
))
{
foreach
(
$entity
->
getPropertyDefinitions
()
as
$field_name
=>
$definition
)
{
if
(
isset
(
$build
[
$field_name
])
&&
$definition
->
getType
()
===
'comment'
)
{
$display_options
=
$display
->
getComponent
(
$field_name
);
$pager_id
=
$display_options
[
'settings'
][
'pager_id'
];
$page
=
pager_find_page
(
$pager_id
);
$build
[
'#cache'
][
'keys'
][]
=
$field_name
.
'-pager-'
.
$page
;
}
}
}
}
/**
* Implements hook_entity_view().
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment