Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Comment::hasParentComment() checks if there is a parent comment, and it does so by checking if it can load an entity.
That has two problems:
a) we might be loading the entity when we don't need it.
b) The default value for that field is 0, which then does a load(0), this is currently not being cached.
To reproduce:
Enable threaded comments, create a node with a bunch of comments without a parent.
Proposed resolution
If possible only check for ->target_id, or at least check that before checking ->entity.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#1 | comment-has-parent-2328629-1.patch | 524 bytes | Berdir |
Comments
Comment #1
BerdirHere's a patch.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedNice performance fix. Thanks.
Comment #3
webchickCommitted and pushed to 8.x. Thanks!