After installing the module and "clear all cached", I changed data on a profile2 user define field. Got the message:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ecodev_dev.cache_entity_profile2' doesn't exist: DELETE FROM {cache_entity_profile2} WHERE (cid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 2 ) in cache_clear_all() (line 169 of /home/ecodev/public_html/includes/cache.inc).
SEVERITY

After removing this module the message is gone and the document is saved.

Would love to have it fixed.

Files: 
CommentFileSizeAuthor
#42 1387268-41-entity-cache-tables.patch1.71 KBtstoeckler
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1387268-41-entity-cache-tables.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#30 profile2-1387268-30.patch922 bytestim.plunkett
PASSED: [[SimpleTest]]: [MySQL] 53 pass(es).
[ View ]
#9 profile2-1387268-9.patch444 bytesnielsonm
PASSED: [[SimpleTest]]: [MySQL] 53 pass(es).
[ View ]

Comments

kervi’s picture

Priority:Normal» Major

same here.

geerlingguy’s picture

Also had this crop up, but only for some users (when saving their profiles).

geerlingguy’s picture

It looks like the problem is that entity cache only sets up tables for entities that existed before the installation of the entitycache module itself (see the implementation of hook_schema() in entitycache.install). Therefore, if you first install the entitycache module, then later install something that creates a new entity, like Profile2, that entity's cache table will never be created.

After testing an uninstall and reinstall, it looks like the cache_entity_profile2 table was still not created; it looks like there's no code to automatically create extra entity tables, but rather it seems each module that supports entity cache would need to build it's own cache table/bin? (From this module's page: "Create a cache_entity_$myentity table/bin.").

In any case, you can manually create the table using db_create_table():

<?php
 
// Get the cache table schema.
 
$schema = drupal_get_schema_unprocessed('system', 'cache');
 
$schema['description'] = "Cache table used to store profile2 entity records.";

 
db_create_table('cache_entity_profile2', $schema);
?>

Perhaps this should be moved to the Profile2 issue queue?

geerlingguy’s picture

Version:7.x-1.1» 7.x-1.x-dev
Status:Active» Needs review
geerlingguy’s picture

Title:PHP & Profile2 Error when saving Profile2 with field changed» Profile2 entity cache table not created, causing PHP exceptions when saving/updating data
webflo’s picture

Project:Entity cache» Profile 2

Yep this is an Profile 2 issue.

webflo’s picture

Status:Needs review» Needs work
erikwebb’s picture

Same issue here. I've actually enabled Entity Cache after Profile2. I see all of the SET commands sent to Memcached on every page load, but no GET commands are ever executed.

nielsonm’s picture

StatusFileSize
new444 bytes
PASSED: [[SimpleTest]]: [MySQL] 53 pass(es).
[ View ]

I created a patch for this based off of @geerlingguy's comment #3 I added the entity cache to the install file. Let me know if this works, or if there's a better way.

Thanks,
Nielsonm

geerlingguy’s picture

Status:Needs work» Needs review
TimelessDomain’s picture

I tried the patch + ran cron/updates & flushed cache, but no difference. Is this patch only for new installs?

I did get it to work finally by adding this to the bottom profile2.install

function profile2_update_7103() {
  // Get the cache table schema.
  $schema = drupal_get_schema_unprocessed('system', 'cache');
  $schema['description'] = "Cache table used to store profile2 entity records.";

  db_create_table('cache_entity_profile2', $schema);
}

nielsonm’s picture

In order for the patch to work, you would have needed to uninstall and re-install the module, as hook_install only gets called during installation. An update hook would work if uninstalling the module is unacceptable.

stopshinal’s picture

After you added this, what did you do to make it work? I've run cron, flushed again, I'm still getting this error. I suppose i'm unsure how to run the update

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'pantheon.cache_entity_profile2' doesn't exist: DELETE FROM {cache_entity_profile2} WHERE (cid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 4 ) in cache_clear_all() (line 169 of /includes/cache.inc).

VisualFox’s picture

@stopshinal You need to call update.php to have this patch working

stopshinal’s picture

Mental blank, thanks!

fago’s picture

Status:Needs review» Needs work

hm, I'm not very happy with having to do this in each entity-providing module in order to support entity-cache. It would also mean we'd end up with lots of unused cache tables if entitycache isn't used.

I'd prefer a solution where we handle the cache tables in or triggered by entitycache.

alexweber’s picture

@fago, in this case, the issue should be in the EntityCache queue and not Profile2!

I agree, entitycache should check what entities enable cache option and handle creating and deleting the necessary tables itself.

geerlingguy’s picture

Well, it was in the EntityCache queue, and was shuffled over here... we could bounce it back, give it a fancy new title, and hope the EntityCache maintainers would find a way to make it work, maybe by defining a list of modules they'd support... but it's kind a chicken-and-egg problem, since they don't want to maintain a list of modules that provide entities, and entity module maintainers don't want to provide support for EntityCache :-/

alexweber’s picture

@geerlingguy I completely understand, however, entitycache support is determined by whether or not the "entity cache" option is passed in hook_entity_info(). Therefore, all they really would have to do is, before writing or reading from cache, check if the table exists and, if not, create it. It's quite simple IMO :)

Pascal.s’s picture

Title:Profile2 entity cache table not created, causing PHP exceptions when saving/updating data» Fixed for me!

I wanted to install de patch but i already had lots of fields configured and didn't want to lose that! (or maybe i did it wrong)
But #11 did it for me!
So as far as i'm concerned for now... For me, it's fixed!

alexweber’s picture

Title:Fixed for me!» Profile2 entity cache table not created, causing PHP exceptions when saving/updating data

Please don't change the title to something meaningless, it will throw people off that are looking for the same solution to your problem!

havran’s picture

For my needs i create this patch which cover creating table by update.php.

diff --git a/sites/all/modules/contrib/profile2/profile2.install b/sites/all/modules/contrib/profile2/profile2.install
index 762b1ff..65487c6 100644
--- a/sites/all/modules/contrib/profile2/profile2.install
+++ b/sites/all/modules/contrib/profile2/profile2.install
@@ -140,6 +140,10 @@ function profile2_schema() {
       'type' => array('type'),
     ),
   );
+
+  $schema['cache_entity_profile2'] = drupal_get_schema_unprocessed('system', 'cache');
+  $schema['cache_entity_profile2']['description'] = "Cache table used to store profile2 entity records.";
+
   return $schema;
}

@@ -204,3 +208,14 @@ function profile2_update_7102() {
     'not null' => FALSE,
   ));
}
+
+/**
+ * Create table {cache_entity_profile2} if not exist.'
+ */
+function profile2_update_7103() {
+  if (!db_table_exists('cache_entity_profile2')) {
+    $schema = drupal_get_schema_unprocessed('profile2', 'cache_entity_profile2');
+
+    db_create_table('cache_entity_profile2', $schema);
+  }
+}

EvanDonovan’s picture

@havran: Looks like a good approach, although fago had said earlier he'd prefer not to do it. Perhaps if the update was wrapped in if(module_exists('entitycache')?

Also, can you post as an actual patch?

erikwebb’s picture

@EvanDonovan: Based on fago's previous comments, it actually sounds like the right implementation would be to add a hook to Entity Cache that can be easily implemented by each entity-providing module. This would be much more repeatable and easy to manage.

EvanDonovan’s picture

Is there an issue for that currently?

jmonkfish’s picture

This fixed a problem where we could not Cancel user accounts.

I applied both #9 and #11, and after running update.php everything works fine.

hejazee’s picture

Status:Needs work» Needs review

#9 and #11 work fine

TimelessDomain’s picture

Status:Needs review» Reviewed & tested by the community
RaulMuroc’s picture

I appplied the patches first because I saw the same error at the topic and It solved that. A few weeks later I ntoiced that the thing was that Entity cache breaks Profile2 so I uninstalled Entity cache. After a few crons profile2 fields disappear (not other fields types) and I think is because of this process: 1) Apply patches. 2) Uninstall entity cache.

What is to do with:

function profile2_update_7103() {
  // Get the cache table schema.
  $schema = drupal_get_schema_unprocessed('system', 'cache');
  $schema['description'] = "Cache table used to store profile2 entity records.";

  db_create_table('cache_entity_profile2', $schema);
}

IT created the table. After I uninstall "Entity Cache" all the profile2 fields (ones created before the patch and even the news after the patch) just do not appear.

:(

tim.plunkett’s picture

StatusFileSize
new922 bytes
PASSED: [[SimpleTest]]: [MySQL] 53 pass(es).
[ View ]

Entity cache's module page explicitly states: "There is no automated support for contrib entities, to use entitycache for a contrib or custom entity: Create a cache_entity_$myentity table/bin."

So I don't think catch plans to change that, and this is a relatively major bug.

Here's an updated patch with the hook_update_N(), but with a db_table_exists() check first.

Kingdutch’s picture

Status:Reviewed & tested by the community» Needs review

I applied the patch in #30 manually (didn't have a git clone lying around) to the current stable version and tried to update but update.php tells me no updates, even after manually bumping the version number and packaging timestamp (perhaps I'm doing something wrong).

Also this patch does not address the issue in #16 about a lot of empty tables in the case entity_cache is not used.

Vale80’s picture

Version:7.x-1.x-dev» 7.x-1.3
Priority:Major» Critical

Hello everyone!

Could you please summarize which is the best solution to fix it for good?

#9 and #11 OR #30 ?

Thanks in advance!

infines’s picture

#30 is currently the most updated patch.

And it worked wonderfully for me.

Vale80’s picture

Thanks gridbitlabs!

Vale80’s picture

I'm new in Drupal, I search around but I can't understand which is the right procedure to apply this patch.
Could you please point me out some urls?
In the Applying a patch Profile2 section, it says:

Download the patch to your working directory. Apply the patch with the following command:
git apply -v [patchname.patch]

Could you please tell me which is my working directory?
And how can I run that command?

The Drupal installation where I want to apply this patch is on a server, is a test site.

Thanks again!

infines’s picture

Please refer to the IRC support channel or the forums for questions like this. This is an issue queue and we need to keep the focus on track. There are many ways to apply a patch. You can read about them here: http://drupal.org/patch/apply

btopro’s picture

patch worked for me. that's multiple confirmed cases of working (I had it work on 3 different installs), is this RTBC?

infines’s picture

@btopro While the patch fixes the error, there were other issues addressed in comment #31 that need to be taken care of or resolved elsewhere. These decisions are partly up to the maintainer.

dawehner’s picture

Status:Needs review» Reviewed & tested by the community

Also this patch does not address the issue in #16 about a lot of empty tables in the case entity_cache is not used.

Sure there is a small problem when there is an empty table, but let's be honest: Which site using profile2 and does not use entitycache have actual problems when they have one single unused table. In general each big site will have to use entitycache, so that is not an issue.
Let's be pragmatic.

The update is for sure found properly.

tstoeckler’s picture

Status:Reviewed & tested by the community» Needs review

I'm pretty sure this is a bug with Entity API, not with Profile2. @tim.plunkett's quote in #30 is correct, but incomplete:

There is no automated support for contrib entities, to use entitycache for a contrib or custom entity:

  • Create a cache_entity_$myentity table/bin.
  • Specify EntityCacheDefaultEntityController as your controller class in hook_entity_info(), or extend it.

Profile2 does not set EntityCacheDefaultEntityController as its class, it sets EntityAPIController provided by Entity API. The latter does manual calls into the controller helper class provided by entitycache, in order to provide automated Entity cache support for entity types (see #1111120: Support for EntityCache). So if Entity API claims to support Entity cache it seems it should also create the tables itself.

Not moving over to Entity module yet, because I would like some feedback on that position, but I fail to see what Profile2 is doing wrong.

tstoeckler’s picture

Here's a patch against Entity API. I must admit that I didn't try it out myself. This does not yet contain an update function either, so people on existing sites won't be helped by this patch.

If you agree with my assessment we could move the issue to Entity API

tstoeckler’s picture

StatusFileSize
new1.71 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1387268-41-entity-cache-tables.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Oops.

Status:Needs review» Needs work

The last submitted patch, 1387268-41-entity-cache-tables.patch, failed testing.

tstoeckler’s picture

Status:Needs work» Needs review

Oops, sorry. I didn't realize Profile2 had testing enabled. The patch is against Entity API 7.x-1.x.

Renee S’s picture

I think this should go to Entity instead. Worth a shot.

Phizes’s picture

Closed #1874274: unable to edit (update) the profile (EntityCache problem) as a duplicate.

I have a sandbox project which I am using as a workaround for this issue on a couple of sites at the moment. It merely contains the schema for the missing cache table.

tstoeckler’s picture

RaulMuroc’s picture

Status:Needs review» Active

Some light on this? Last patch does not work and even does not past the Drupal test.

Critical because if used when Profile2 modules enabled, it breaks the page completely.

deggertsen’s picture

I am using the sandbox project mentioned in #46 for the time being and it is working fine. Can't wait until #2017685: Automatically create cache tables for entities that want to support entitycache.module is fixed, but I don't really have the know-how to help much there.

tstoeckler’s picture

For anyone having this issue: The patch in #30 works fine. Note that you need to run update.php after applying it.

Grayside’s picture

#30 works for me.

RaulMuroc’s picture

Status:Active» Reviewed & tested by the community

About patch in #30:
- Many people confirm it works.
- It passed drupal's test.

Changing status.

jhedstrom’s picture

Agree with #52, RTBC.

dasjo’s picture

please have a look at our generic approach: #2017685-4: Automatically create cache tables for entities that want to support entitycache.module
i guess this might lead to a won't fix for the profile2 patch

fago’s picture

We should create the table only when needed i.e. entitycache module is there. #2017685: Automatically create cache tables for entities that want to support entitycache.module takes care of that - so let's make use of that functionality once landed. Please help testing the patch over there to move on with this faster.

RaulMuroc’s picture

I prepared a development environment cloned from the latest having problemas and applied patch in the other issue. Works fine for me.

I'm moving on the other issue. Perhaps this issue could be marked as duplicate and we could just attach the patch of #30 to the other issue (for the case).

tobiasb’s picture

Version:7.x-1.3» 7.x-1.x-dev
Issue summary:View changes
Status:Reviewed & tested by the community» Needs work
axel.rutz’s picture

Status:Needs work» Fixed

Yes this is fixed for me with current entity-7.x-1.5
:-)))

Status:Fixed» Closed (fixed)

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

maranjo’s picture

Just to say this is still valid: patch #30 required for me with drupal 7.32 and both latest dev versions of profile2 (7.x-1.3+6-dev) and entity api (7.x-1.5+7-dev).
Thanks to all for providing and advising!

Spleshka’s picture

@maranjo, can you please provide a steps to reproduce this issue? If it is still valid, then we definately have to tix this.

maranjo’s picture

@spleshka I can't really say what the steps were. I simply have profile2 installed as mentioned, and I saw the error shown at the start of this post whenever I try to run update.php (for any reason). I also saw the error when I tried to delete a user account using a vbo action, such that the account wouldn't delete.
This is on a pretty complex D7 website, so my guess it arose as a result of some sequence of installing modules over a period of months. I couldn't understand why the table cache_entity_profile2 was missing, but applying that patch (#30) did the trick and so I don't need to worry about it now.

Spleshka’s picture

As far as I see, this patch wasn't commited to profile2, that's why it fixed problem for you after you applied it. But I still can't explain why entity_cache module doesn't create a table for profile2 automatically.