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.
Regardless of whether Drupal core thinks that static caching should be disabled for comments by default or not,
there is hook_entity_info_alter(), and the 'static cache'
property can be changed freely,
so comment loading functions should follow other entity loaders and have a $reset argument.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1000282-comment-load-reset-4.patch | 1.6 KB | dixon_ |
drupal.comment-load-reset.0.patch | 1.74 KB | sun | |
Comments
Comment #1
sunComment #2
sundrupal.comment-load-reset.0.patch queued for re-testing.
Comment #3
dixon_Comment #4
dixon_Re-rolled patch because of offset.
Comment #5
sunThanks!
Comment #6
dixon_Patch applies to D7 without offset, so should be ready for straight backport.
Comment #7
catchCommitted to 8.x, moving back to 7.x for webchick. This is an extra argument, so an API addition, and you could technically get around it via calling entity_load() directly, but it's good for consistency with the other entity functions and arguably a bug that we allow you to change the static caching via alter but no obvious way to clear that static if you do.
No tests here but everything gets passed straight down to entity_load() which does have them.
file_load() is also missing this, opened a followup at #1292374: Enable static caching for File entities.
Comment #8
webchickYeah, this looks harmless. Committed and pushed to 7.x. Thanks!
(Note: I thought the entire point of the drupal_static() obfuscation so we didn't have to do this $reset parameter crap everywhere?)
Comment #9
catchAh that's because entity static caching is inside the load controller class. But the only way to directly access that method is via _entity_get_controller(). So in D8 we'll be able to remove all the $reset for entities if the controller methods are exposed rather than wrapped in node_load() etc., but there's no nice way to do that yet.