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

Issue fork drupal-3256091

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gaurav.manerkar created an issue. See original summary.

gaurav_manerkar’s picture

Issue summary: View changes
Issue tags: -Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\ContentEntityStorageBase->loadMultipleRevisions() +drupal core
gaurav_manerkar’s picture

Status: Active » Closed (works as designed)
mvnovick’s picture

I am getting the same two warnings in 9.3.6. How did you resolve this issue?

sahilgidwani’s picture

Version: 9.3.x-dev » 9.5.x-dev
Status: Closed (works as designed) » Active
Issue tags: -

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.

no sssweat’s picture

StatusFileSize
new950.71 KB
new964.68 KB

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 when trying to view revisions.
(Ex: /node/5715/revisions/79204/view)

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 Symfony 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)

no sssweat’s picture

As mentioned in comment #6, because of the different Symfony 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.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

samit.310@gmail.com made their first commit to this issue’s fork.

samitk’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Think it needs to be determined why that's empty and findings be added to the issue summary. Just putting a simple check most likely could be masking a larger issue.

acbramley’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

This needs steps to reproduce now that D9 is unsupported.

acbramley’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

I am closing this as outdated, based on #13

Crediting @no sssweat for the comprehensive debugging.

mrsoundmaurix’s picture

This patch works for Drupal 10.6.1