Warning : array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController

Created on 4 October 2012, about 12 years ago
Updated 12 March 2024, 8 months ago

Problem/Motivation

When using Field Collections with the Entity API, its frequently reported that unexplained, hard to debug, PHP warnings related to array_flip creep into the site. This is most often the case after a site upgrade from Drupal 6 to 7, content import from another site, or database sync.

An example of the warnings that result are:

Warning : array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /includes/entity.inc).

Proposed resolution

Whenever the Entity API attempts to use the PHP builtin array_flip(), on a variable or parameter of mixed or undefined type, it should ensure:

  1. That the variable or parameter being flipped is an array.
  2. That the values in the array can be used as array keys (ie. are not NULL values)

Remaining tasks

  1. Tests: Pass non-array values into methods that accept mixed type parameters
  2. Tests: Pass empty values into methods that accept mixed type parameters
  3. Tests: Pass NULL values into methods that accept mixed type parameters

Original report by Emerya.thomas

Warning : array_flip(): Can only flip STRING and INTEGER values! dans DrupalDefaultEntityController->load() (ligne 178/includes/entity.inc).
Only happen with field collection load, have got last release entity & field collection.
I try to look, but I don't understand, field collection send always an array... I dunno if after field collection need to load other entity wich can make this warning.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Entity CRUD controller

Created by

πŸ‡«πŸ‡·France musa.thomas France πŸ‡«πŸ‡·

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024