Description

Entity API allows entity types to support entitycache.module simply by adding the 'entity cache' => TRUE flag (conditionally) in hook_entity_info(). It then automatically retrieves the cached entities from the appropriate tables.

It does not however create the tables, each module needs to do that manually. Not doing that (in case of Profile2) leads to fatal errors, because non-existing database tables are being accessed.

Remaining tasks

Convince @fago that we should do this. When that is done, we can take the patch from #1336924-8: Default to use EntityCache if available, and create necessary cache bin tables as a starting point for this.

Related issues

#1387268: Profile2 entity cache table not created, causing PHP exceptions when saving/updating data
#1336924: Default to use EntityCache if available, and create necessary cache bin tables

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RaulMuroc’s picture

Priority: Normal » Major

Convince @fago that we should do this

Are you kidding man? If he is a maintainer or co-maintainer and has time then he should work on solving this point, we do not have to convince him because if this feature is not repaired basically this module is unuseful and can be deprecated. :S

It mas have automatic detection of required entities for cache because every site has different entities and we cannot "play rulette" that maybe breaks the page maybe not.

And of course, everyone interest shoudl help to achieve this goal!

Sorry for contundence, I'm :) anyway and hope you too.

fago’s picture

Status: Active » Needs work

Ok, had a look at this together with dasjo. https://drupal.org/node/1336924#comment-7415234 is a good starting point, however let's do:

+++ b/entity.module
@@ -843,6 +843,77 @@ function _entity_defaults_rebuild($entity_type) {
+          // The following two conditions duplicate entity_crud_get_info(), but

Let's just use the helper + rely on the info 'module' key to match any of the installed modules. Yes we require devs to implement our own API ;-) Also document that entity cache support requires the module key to be specified at our entity_crud_hook_entity_info() 'entity cache' docs.

- hook_entity_info_alter() should be extended to disable "field-cache" automatically when entity cache is enabled and the module there.

- We should add all tables only when the module is there, and drop them if entitycache is uninstalled. Maybe best keep the install/uninstall logic in the .install file and call the helper from the hooks only to avoid cluttering the .module file further.

dasjo’s picture

Assigned: Unassigned » dasjo
Issue summary: View changes

will post a patch soon

dasjo’s picture

Status: Needs work » Needs review
FileSize
6.13 KB

here's what i tested using the while module:

tables are created after entitycache install
tables are created after while install
tables are deleted after entitycache uninstall
tables are deleted after while while uninstall

dasjo’s picture

Assigned: dasjo » Unassigned
fago’s picture

Status: Needs review » Needs work

Patch looks good and seems to work fine. Here a few minor remarks:

  1. +++ b/entity.install
    @@ -26,3 +26,101 @@ function entity_update_7001() {
    + * Remove entity cache tables for supporting entity types of uninstalled modules.
    

    Summary is 1 char too long.

  2. +++ b/entity.install
    @@ -26,3 +26,101 @@ function entity_update_7001() {
    + *   (optional) An array of uninstalled modules.
    + *   If not specified, try to remove cache tables for all modules.
    

    To early line break.

  3. +++ b/entity.install
    @@ -26,3 +26,101 @@ function entity_update_7001() {
    +  foreach($modules as $module) {
    

    Missing space after foreach.

fago’s picture

Status: Needs work » Needs review
FileSize
6.92 KB

Figured we miss hook_flush_caches() impl and should create tables on hook_enable().

Also addressed above remarks.

fago’s picture

Status: Needs review » Reviewed & tested by the community

Patch seems to work fine now - so this should be good to go. Further testers would be welcome!

fago’s picture

Status: Reviewed & tested by the community » Needs work

Figured this uses required_once with a relative path - which it shouldn't as it depends on the configured include path. Instead it should use module_load_install('entity');

dasjo’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
6.92 KB
689 bytes

implemented suggested changes from #9

fago’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

alexweber’s picture

Awesome, thanks for all the great work everyone! :)

Jody Lynn’s picture

So, was this committed?

fago’s picture

Status: Reviewed & tested by the community » Fixed

This seems to work fine, thus - committed.

Status: Fixed » Closed (fixed)

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