Hi everyone,

Not sure where to post this as I don't know why this error is occuring. I have 2 taxonomies, category & tags on a node. When I use the checkboxes/dropdown, no error. When I use autocomplete widget, I get this as a system message:

Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/MY-USERNAME/Drupal/includes/entity.inc).

The specific part of entity.inc is this:

    // Exclude any entities loaded from cache if they don't match $conditions.
    // This ensures the same behavior whether loading from memory or database.
    if ($conditions) {
      foreach ($entities as $entity) {
        $entity_values = (array) $entity;
        if (array_diff_assoc($conditions, $entity_values)) {    <---THIS IS LINE 368
          unset($entities[$entity->{$this->idKey}]);
        }
      }
    }
    return $entities;
  }

The node reloads after pressing 'Save', I get this error at the top, but the text I have put into the autocomplete is there on the page, and links to the taxonomy term page i.e. everything 'works' but what is this error?

I can repost this in the correct place if anyone knows why this error is occuring. I'm not Drupal expert so not sure how to follow this up.

Sam.

Comments

samwillc’s picture

Does anyone know what this means? I still can't use free tagging on any of my nodes.

Saving gives this error. I updated the entity api module to latest version and still this persists. Thought it might be taxonomy menu but I have never enabled it on this test site.

Could it be the media module?

Sam.

samwillc’s picture

Ok, totally fresh install of Drupal 7, standard modules enabled, using default bartik theme.

Create article > tagged > saved, all good, tags display on page, no problems.

Enabled entity api, (7.x-1.0-rc3+10-dev), edit article (didn't change anything) > resaved article, result:

    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).
    Notice: Array to string conversion in DrupalDefaultEntityController->cacheGet() (line 368 of /Users/Sam/Drupal/testsite/includes/entity.inc).

Status message
Article My article has been updated.

Seems clear where the problem lies now. I will create an issue and direct it to this post.

Sam.

Ruben23’s picture

jgoldbloom’s picture

I think this is a known bug, they think they got it fixed in D8 but from what I can tell its not been successfully back ported to D7 yet:

http://drupal.org/node/1525176 <- read all comments

Being its a PHP notice you're likely seeing it on a dev instance with logging options set to show all notices, warnings and errors but on production you likely have these disabled so it won't matter there. I didn't sense the Drupal gods want to bend over backwards on this one due to it being a notice only. Feel free to complain in that topic and try the patch if it bugs you, but as of this writing the last D7 patch failed testing. ;-)

samwillc’s picture

Thanks for the info. Now I can see better what the issue is.

I got this response: http://drupal.org/node/1804838

Unfortunately, I'm not in a position to fix this myself.

Sam.

kreatil’s picture

Right since I have upgraded from php 5.2.12 to 5.4.9 I also get this same error after editing nodes. Running php as Apache module.

andrea.cavattoni’s picture

Yes is php 5.4, you just have to replace the line with

if (array_diff_assoc_recursive($conditions, $entity_values)) {

and add this function in the core or ina custom module:

function array_diff_assoc_recursive($array1, $array2) {
  foreach ($array1 as $key => $value) {
    if (is_array($value)) {
      if (!isset($array2[$key])) {
        $difference[$key] = $value;
      } elseif (!is_array($array2[$key])) {
        $difference[$key] = $value;
      } else {
        $new_diff = array_diff_assoc_recursive($value, $array2[$key]);
        if (count($new_diff) > 0) {
          $difference[$key] = $value;
        }
      }
    } elseif (!array_key_exists($key, $array2) || $array2[$key] != $value) {
      $difference[$key] = $value;
    }
  }
  return !isset($difference) ? array() : $difference;
}
alesr’s picture

Here is the opened issue https://drupal.org/node/1525176

Ruben23’s picture

samwillc’s picture

Thanks everyone, I've got a site coming up which will need the autocomplete working, I will test some of the solutions offered.

dlu’s picture

samwillc’s picture

Thanks :)