Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
socialbase
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
socialbase
Commits
6d83d842
Commit
6d83d842
authored
3 years ago
by
Dmytrii Kaiun
Committed by
Andrii Chyrskyi
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3259745
by tBKoT: Use commen_count property instead of function
parent
1d7163ce
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!91
Issue #3259745: Comment count function is too slow
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
socialbase.theme
+3
-0
3 additions, 0 deletions
socialbase.theme
src/Plugin/Preprocess/Field.php
+1
-1
1 addition, 1 deletion
src/Plugin/Preprocess/Field.php
src/Plugin/Preprocess/Node.php
+1
-1
1 addition, 1 deletion
src/Plugin/Preprocess/Node.php
with
5 additions
and
2 deletions
socialbase.theme
+
3
−
0
View file @
6d83d842
...
...
@@ -109,6 +109,9 @@ function _socialbase_get_join_method_icon($title) {
/**
* Get comment count for a node.
*
* @deprecated
* Use $entity->get(<comment_field_name>)->comment_count instead this function.
*/
function
_socialbase_node_get_comment_count
(
NodeInterface
$node
)
{
$comment_count
=
&
drupal_static
(
__FUNCTION__
.
$node
->
id
());
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Preprocess/Field.php
+
1
−
1
View file @
6d83d842
...
...
@@ -70,7 +70,7 @@ class Field extends PreprocessBase {
$node
=
!
empty
(
$attached
[
'#object'
])
?
$attached
[
'#object'
]
:
NULL
;
// Count the amount of comments placed on a Node..
if
(
$node
instanceof
Node
)
{
$comment_count
=
_socialbase_
node
_
get
_
comment_count
(
$node
)
;
$comment_count
=
(
int
)
$
node
->
get
(
$element
[
'#field_name'
])
->
comment_count
;
// Add it to the title.
$variables
[
'comment_count'
]
=
$comment_count
;
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Preprocess/Node.php
+
1
−
1
View file @
6d83d842
...
...
@@ -173,7 +173,7 @@ class Node extends PreprocessBase {
// OPEN or CLOSED we can render icon for
// comment count, and add the comment count to the node.
if
(
$node
->
$comment_field_name
->
status
!=
CommentItemInterface
::
HIDDEN
)
{
$comment_count
=
_socialbase_
node
_
get
_
comment_count
(
$node
)
;
$comment_count
=
(
int
)
$
node
->
get
(
$comment_field_name
)
->
comment_count
;
$variables
[
'below_content'
][
$comment_field_name
][
'#title'
]
=
$comment_count
===
0
?
t
(
'Be the first one to comment'
)
:
t
(
'Comments'
);
// If it's closed, we only show the comment section when there are
...
...
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