I updated to the dev version of Entity API, and now on one of my two sites when I clear the cache I get:

Notice: Array to string conversion in EntityAPIControllerExportable->applyConditions() (line 625 of /etc/drupal/7/sites/all/modules/entity/includes/entity.controller.inc).

#20 1514764-fix_entity_conditions-20.patch1.11 KBamateescu
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View
#18 1514764-fix_entity_conditions.patch1.03 KBamateescu
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View
#15 entity-array_diff_assoc-1514764-15.patch743 bytesyuriy.babenko
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View
#11 entity module fail on 624.PNG57.75 KBshaiss
#10 Screenshot from 2012-05-18 22:16:10.png55.97 KBrogical


paulcheck’s picture

Has anyone else had this problem? For some reason it only appears on one of two sites, despite sharing much of the modules, etc, in common.

alexweber’s picture

Status: Active » Postponed (maintainer needs more info)

Can't replicate this at all, I've been using the dev version all weekend.

What modules are you using that require Entity API?

lEaDbEllY’s picture

I'm getting this too. Its not really stopping much, just annoying (AFAICT). I have a big gob of modules available (I load modules automatically so they all get installed the same way).

The ones requiring Entity API are:
Date iCal
OG example
Entity Reference
Entity Reference Behavior Example
Rules translation (is available in modules but not installed --no check mark)
Organic groups
Organic groups access control
Organic groups context
Organic groups field access
Organic groups migrate (is available in modules but not installed --no check mark)
Organic groups register
Organic groups UI
Profile2 group access
Entity API
Entity tokens
Profile2 pages
Rules Scheduler
Rules UI
Views Bulk Operations
Workflow rules

... the large number may make it a bear to chase down exactly *where* something is breaking. The needle is small and the haystack very large. Its a bit of a test site. I have 56 modules available (not all are installled). I only listed the modules that use Entity API. I'm running drupal-7.12, and php-5.4.0.


paulcheck’s picture

Sry for the delay. The modules that require Entity that I have installed and enabled are:

Entity tokens (enabled), Rules (enabled), Commerce (enabled), Commerce UI (enabled), Customer (enabled), Price (enabled), Line Item (enabled), Order (enabled), Payment (enabled), Authorize.Net (enabled), Checkout (enabled), Product (enabled), Product Reference (enabled), Rules UI (enabled), Product Pricing (enabled), Cart (enabled), Commerce Checkout Progress (enabled), Customer UI (enabled), Commerce File (enabled), Line Item UI (enabled), Commerce Multicurrency (enabled), No Payment Payment Method (enabled), Order UI (enabled), Payment Method Example (enabled), Payment UI (enabled), Physical Product (enabled), Product Pricing UI (enabled), Product UI (enabled), Shipping (enabled), Shipping Method Example (enabled), Flat Rate (enabled), Shipping UI (enabled), Tax (enabled), Tax UI (enabled), UPS (enabled), Rules translation (enabled), Rules Scheduler (enabled)

Given that I have two sites and one of them doesn't have Commerce or Shipping enabled and also doesn't show the error, perhaps it is one of those groups. I could try to selectively enable the modules that are missing on the second site and see if I can trigger it, or conversely disable those modules on the site where the error is occuring (probably a better strategy).

The error occurs so far only when I clear the cache. -P

paulcheck’s picture

This might not directly help, but I disabled a number of modules in the various commerce sections and was able to get rid of the error. Note that depending on which modules I have installed I get different numbers of the same error. Anyway, here is the list of modules that depend on Entity API, that I disabled in order to have no errors when I clear the cache:

Required by: Payment (disabled), Authorize.Net (disabled), Checkout (disabled), Cart (disabled), Commerce Checkout Progress (disabled), Line Item UI (disabled), No Payment Payment Method (disabled), Order UI (disabled), Payment Method Example (disabled), Payment UI (disabled), Physical Product (disabled), Product Pricing UI (disabled), Shipping (disabled), Shipping Method Example (disabled), Flat Rate (disabled), Shipping UI (disabled), Tax UI (disabled), UPS (disabled)

Hope this helps?

alexweber’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

This seems like a clear case of one or more of those modules relying specifically on an older version of Entity API.

There have been some changes in recent versions of Entity API that could potentially break things if other modules don't follow suit and update themselves (or specify what specific version of Entity API is required for them).

paulcheck’s picture

Do you say it's clear because the problem goes away when I delete those modules? Is it possible that entity has an error that's getting triggered by those modules? After all, the error is happening in an entity routine. Any idea on what change in this case is causing the error?

raveendrab’s picture

Problem exists with core 7.14. Every time I try to clear cache, the error dsiplayed. I am using rooms, commerce modules which depends on entity api. This is clean installation with out any content.

kotnik’s picture

I am having this issue with PHP 5.4.3, but not with 5.3.13.

As people migrate to PHP 5.4, we will see more and more issues like this.

rogical’s picture

Status: Closed (works as designed) » Active
55.97 KB


shaiss’s picture

Version: 7.x-1.x-dev » 7.x-1.0-rc3
57.75 KB

same happens to me on flush caches but on line 624 after updating entity to rc3 and rules 2.1

Same thing happens on rc2

shaiss’s picture

I had the same issue. I moved my site to my dev host running php 5.3.1 and issue went away.

A similar issue is happening with the rules module: http://drupal.org/node/1463678#comment-6069000

paulcheck’s picture

Fresh update to commerce and I'm still getting the error. Are the commerce people aware? It sounds like a problem with commerce, not entity.

kotnik’s picture

Paulcheck, this *is* Entity API issue with PHP 5.4 and there's nothing commerce module can do to solve it. It happens with other modules that rely on Entity API.

Downgrade to PHP 5.3 if you want to avoid this, and wait for Entity API fix for the issue.

yuriy.babenko’s picture

Status: Active » Needs review
743 bytes
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View

Ran into this issue after updating to PHP 5.4.3 earlier today, and am attaching a patch.

Note: this solves the notice in my environment and at quick glance appears to be the same functionality as provided by array_diff_assoc() (as far as Entity's use case goes), but I didn't do any extensive testing and this patch definitely needs a review by someone more familiar with Entity's internals.

rogical’s picture

Status: Needs review » Reviewed & tested by the community

It works!

deepbluesolutions’s picture

works for me too, well the error has gone, and seeing no side effects at the moment.

there are similar errors all over, for 5.4 PHP users, http://drupal.org/node/1511396

for example:

Notice: Array to string conversion in views_plugin_cache->gather_headers() (line 196 of /var/www/html/sites/all/modules/views/plugins/views_plugin_cache.inc).

having been trying to see if a similar approach works with the code in views_plugin_cache, but not much joy at the moment, will update when I have more.

your code

if ($conditions) {
foreach ($entities as $key => $entity) {
$entity_values = (array) $entity;
+ foreach ($conditions as $c_key => $c_value) {
+ if (!isset($entity_values[$c_key]) || serialize($c_value) != serialize($entity_values[$c_key])) {
+ unset($entities[$key]);
+ break;
+ }

views code

$this->storage['css'] = array_diff_assoc($css, $css_start);

amateescu’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
1.03 KB
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View

I think the correct patch should be something like this. Also see http://drupal.org/node/1525176#comment-6317632.

fago’s picture

Status: Needs review » Needs work
+++ b/includes/entity.controller.inc
@@ -621,8 +621,18 @@ class EntityAPIControllerExportable extends EntityAPIController {
+            if (!isset($entity_values[$condition_key])) {
+              unset($entities[$key]);
+            }
+            elseif (!in_array($entity_values[$condition_key], $condition_value)) {

Let's just do a single if with an OR here?

amateescu’s picture

Component: Code - misc » Entity CRUD controller
Status: Needs work » Needs review
1.11 KB
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es). View

Sure, with a comment too :)

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community

thanks, that was pretty annoying error

fago’s picture

Status: Reviewed & tested by the community » Fixed

Oh, sry for getting this one. Committed and pushed.

kewigro’s picture

I'm not clear on how to fix this error. Do I need to insert the code from the patch somewhere? Where would I put it? I'm new to drupal and php. Any help would be appreciated.

szt’s picture

@kewigro: as #22 said the issue solved, and comitted: use the latest 7.x-1.x-dev version

mgriebe’s picture

Status: Closed (fixed) » Fixed

@kewigro: You need to either 1) apply the patch or 2) update to the dev version of the module. Check out http://drupal.org/patch/apply. You can apply it "by hand" by reading the patch and seeing what it does and where it does it.

Consider the patch...

diff --git a/includes/entity.controller.inc b/includes/entity.controller.inc
index 1a2812e..76569c1 100644
--- a/includes/entity.controller.inc
+++ b/includes/entity.controller.inc
@@ -621,8 +621,17 @@ class EntityAPIControllerExportable extends EntityAPIController {
     if ($conditions) {
       foreach ($entities as $key => $entity) {
         $entity_values = (array) $entity;
-        if (array_diff_assoc($conditions, $entity_values)) {
-          unset($entities[$key]);
+        // We cannot use array_diff_assoc() here because condition values can
+        // also be arrays, e.g. '$conditions = array('status' => array(1, 2))'
+        foreach ($conditions as $condition_key => $condition_value) {
+          if (is_array($condition_value)) {
+            if (!isset($entity_values[$condition_key]) || !in_array($entity_values[$condition_key], $condition_value)) {
+              unset($entities[$key]);
+            }
+          }
+          elseif (!isset($entity_values[$condition_key]) || $entity_values[$condition_key] != $condition_value) {
+            unset($entities[$key]);
+          }

The path of the patch is written relative to the module root. In this case, the module root is "sites/all/modules/entity". The patch will write to "sites/all/modules/entity/includes/entity.controller.inc". The minuses are lines that will be deleted. The pluses are lines that are added. The lines with neither minuses nor pluses are there for context must be matched in the file or the patching process will throw errors or "ignore hunks." The @@ is a summary that tells you, in this case, that the subtractions start at line 621, as do the additions. Each hunk has it own @@ summary. That's pretty much it.

Status: Fixed » Closed (fixed)

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

redshield’s picture

Status: Fixed » Closed (fixed)

I was having the same issue and managed to get rid of this notices by disabling the following modules:
Messages Example
Messages OG Examples
OG Examples

joachim’s picture

Could this fix maybe warrant a new RC release please?

Ilikejava’s picture

I had this problem that was causing safe_value to miss-behave with a number of fields of nodes on my site. When I updated ['value'], it was storing the new data in ['safe_value']. I had a suspension that the error associate with the entity module had something to do with it. Sure enough, I installed the patch in #20. The error message went away and now my data is behaving.

Thanks for all the efforts.

waqarit’s picture

#15 worked for me. thanks