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
Comments
Comment #2
gaurav_manerkar commentedComment #3
gaurav_manerkar commentedComment #4
mvnovick commentedI am getting the same two warnings in 9.3.6. How did you resolve this issue?
Comment #5
sahilgidwani commentedI am reopening this issue, as I am getting warnings and errors, as mentioned in the descriptions in version 9.5.9 and PHP 8.
Comment #6
no sssweat commentedAfter 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)
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.responsewhile 8.1 does akernel.controllerevent.Also 7.4 has more service definitions while 8.1 has less (802 vs 754)
Comment #7
no sssweat commentedAs 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.
Comment #11
samitk commentedComment #12
smustgrave commentedThink 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.
Comment #13
acbramley commentedThis needs steps to reproduce now that D9 is unsupported.
Comment #14
acbramley commentedI am closing this as outdated, based on #13
Crediting @no sssweat for the comprehensive debugging.
Comment #15
mrsoundmaurix commentedThis patch works for Drupal 10.6.1