Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #1851398: PDOException:Invalid text representation when attempting to load an entity with a string ID
Postponed on #1851398: PDOException:Invalid text representation when attempting to load an entity with a string ID
By @joelpittet:
It may be good to log the error as it seems likely that there may be an error in code that is passing values up the stack. At least array_flip errors seem to be popping up like that for me;)
Comment | File | Size | Author |
---|---|---|---|
#9 | go-up-the-frame.png | 347.17 KB | michaellenahan |
#9 | how-to-fix-can-only-flip-string-and-integer-values.png | 204.75 KB | michaellenahan |
#1 | 2516094-1-entitycache_fix_arry_flip.patch | 886 bytes | RoySegall |
|
Comments
Comment #1
RoySegall CreditAttribution: RoySegall at Gizra commentedI got the same issue in OpenScholar with migration. I'm attaching a small patch which based on #1102570: array_flip() [function.array-flip] issue in DrupalDefaultEntityController / entity.inc
Comment #2
RoySegall CreditAttribution: RoySegall at Gizra commentedComment #3
stefan.r CreditAttribution: stefan.r commentedThat's not "logging an error" ;)
Have a look at entityCacheCleanIds
Are you using the 1.5 version?
Comment #4
RoySegall CreditAttribution: RoySegall at Gizra commentedYap.
Comment #5
tempo22 CreditAttribution: tempo22 commentedIs this regarding the "Warning: array_flip(): Can only flip STRING and INTEGER values!" warnings that started to appear with last version ?
I'm running the 7.x and since last version, my logs are filled with thoses warning. I never bothered since the website was running well anyway.
Comment #6
joelpittetIt usually turns out there is some bad code (either yours or contrib) if you see this happen but it's kind of tricky to debug.
The last time I saw this
array_filter($ids, 'strlen')
didn't work because the $ids was an accidental array passed intonode_load($nid = array(1234));
.Putting in a decent check would be a nasty performance hit I'd assume...
Comment #7
tempo22 CreditAttribution: tempo22 commentedYes, i don't mind fixing the code making the bad code but it's hard to figure where it is :(
Comment #8
joelpittetSetting a breakpoint and looking at the
$ids
helped and up the callstackComment #9
michaellenahan CreditAttribution: michaellenahan at erdfisch commentedA few notes to explain what @joelpittet means here.
It is very likely that the error is in your own custom code. Here's how I found what was wrong in my code.
To do this, you need an IDE such as PHPStorm, so that you can debug and set breakpoints. I'm using PHPStorm.
In my case, the error was coming from line 73 of entitycache.entitycachecontrollerhelper.inc - see Screenshot: https://www.drupal.org/files/issues/how-to-fix-can-only-flip-string-and-...
I put a conditional breakpoint on the next executable line (for me, this was line 78
if ($conditions) {
). This conditional breakpoint had the Conditionempty($passed_ids)
- doing this means the breakpoint gets hit far fewer times.When the breakpoint hits, look in the Frames to see if you can find any of your own custom code. In my case it was a user_load() call where the $uid was NULL. See Screenshot: https://www.drupal.org/files/issues/go-up-the-frame.png
Comment #10
joelpittet@michaellenahan thanks, I rarely give enough information;)