Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\ContentEntityStorageBase->loadMultipleRevisions() (line 666 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).

Created on 27 December 2021, over 2 years ago
Updated 17 October 2023, 9 months ago

Problem/Motivation

Hi, After updating Drupal core from 9.2.10 to 9.3.0, i have getting two warnings on node entity revision page. Note that content types have moderation state enabled.

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\ContentEntityStorageBase->loadMultipleRevisions() (line 666 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).

Warning: Illegal offset type in Drupal\Core\Entity\ContentEntityStorageBase->loadRevision() (line 635 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).

Steps to reproduce

Update Drupal core from 9.2.10 to 9.3.0.
Open any node revision page, Example: /node/5261/revisions/124171/view

Proposed resolution

Warning should not be thrown and code should handle any null value if passed

🐛 Bug report
Status

Active

Version

9.5

Component
Node system 

Last updated about 17 hours ago

No maintainer
Created by

🇮🇳India gaurav_manerkar Vasco Da Gama, Goa

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.

  • 🇮🇳India sahilgidwani Jaipur

    I am reopening this issue, as I am getting warnings and errors, as mentioned in the descriptions in version 9.5.9 and PHP 8.

  • 🇨🇦Canada No Sssweat

    After upgrading from PHP 7.4 to 8.1

    I am also seeing the type error and the array flip warning that comment #5 mentions with Drupal 9.5.11

    TypeError: Illegal offset type in Drupal\Core\Entity\ContentEntityStorageBase->loadRevision() (line 636 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php)

    Warning: array_flip(): Can only flip string and integer values, entry skipped in Drupal\Core\Entity\ContentEntityStorageBase->loadMultipleRevisions() (line 667 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php)

    Going through the code in xdebug for some reason with PHP 8.1 it triggers different kernel events compared to 7.4 with the same codebase and DB.

    7.4 does a kernerl.response while 8.1 does a kernel.controller event.

    Also 7.4 has more service definitions while 8.1 has less (802 vs 754)

  • 🇨🇦Canada No Sssweat

    As mentioned in comment #6, because of the different kernel events. Different values end up being passed to the error and the warning lines.

    One of these values is an empty revisions array and a node object as a revision id instead of a string or int.

    This might not be the optimal solution, but I manage to get passed those by checking if it's not empty.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & sqlite-3.27
    last update 8 months ago
    30,341 pass
Production build 0.69.0 2024