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.
There are more strict warnings:
# Strict warning: Non-static method NodeController::buildQuery() should not be called statically, assuming $this from incompatible context in EntityCacheNodeController->buildQuery() (line 158 of entitycache.module).
# Strict warning: Non-static method CommentController::buildQuery() should not be called statically, assuming $this from incompatible context in EntityCacheCommentController->buildQuery() (line 206 of entitycache.module).
I refactored the module so controllers extend their original controller while using a helper class to get/set the cache. I needed to wrap the EntityCacheCommentController in a module_exists('comment') if-block to prevent errors of extending an unresolvable class.
Comment | File | Size | Author |
---|---|---|---|
#2 | echelper2.patch | 13.73 KB | casey |
echelper.patch | 13.26 KB | casey | |
Comments
Comment #1
catchThanks for this, extending the core controllers plus the helper is a good idea.
Couple of questions though:
The patch sets 'static cache' => TRUE for all entity types. Core specifically doesn't do this for comments and files since they're rarely loaded more than once per page, and for comments they're potentially loaded in large numbers so there's a good chance of bloating memory use for something that will only be requested once anyway.
It looks like this is done because otherwise the cacheSet and cacheGet methods won't be called at all. I don't see another way around this except for overriding load() - could we add that to the helper?
Also, I really don't like executing module_exists() in the raw .module file, looks like we could move the entity classes to .inc and let the registry handle it instead.
Comment #2
casey CreditAttribution: casey commentedAt your request.
Comment #3
catchOh nice! Read through the patch and it looks great, will commit once the bot goes green.
Comment #4
catchCommitted to HEAD.
Comment #6
rm88 CreditAttribution: rm88 commentedhttp://groups.drupal.org/node/217529#comment-883203 This links resolve the problem!