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.

CommentFileSizeAuthor
#2 echelper2.patch13.73 KBcasey
echelper.patch13.26 KBcasey
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Thanks 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.

casey’s picture

FileSize
13.73 KB

At your request.

catch’s picture

Oh nice! Read through the patch and it looks great, will commit once the bot goes green.

catch’s picture

Status: Needs review » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rm88’s picture