Problem/Motivation
The following error is produced when clicking the Moderation sidebar link in the toolbar. This is because the routeMatch finds the moderation sidebar route which doesn't have an entity type's ID route parameter (e.g node), instead it uses entity_type and entity.
Warning: array_flip(): Can only flip string and integer values, entry skipped in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 312 of /data/app/core/lib/Drupal/Core/Entity/EntityStorageBase.php) #0 /data/app/core/includes/bootstrap.inc(347): _drupal_error_handler_real() #1 [internal function]: _drupal_error_handler() #2 /data/app/core/lib/Drupal/Core/Entity/EntityStorageBase.php(312): array_flip() #3 /data/app/core/lib/Drupal/Core/Entity/EntityStorageBase.php(296): Drupal\Core\Entity\EntityStorageBase->loadMultiple() #4 /data/app/modules/contrib/entity_hierarchy/src/Routing/ReorderChildrenAccess.php(85): Drupal\Core\Entity\EntityStorageBase->load() #5 [internal function]: Drupal\entity_hierarchy\Routing\ReorderChildrenAccess->access()
Steps to reproduce
Install Moderation sidebar
Click Sidebar link in the Toolbar
Proposed resolution
Either
- Check for $entity being NULL
- OR fallback to a generic entity route parameter key.
Comments
Comment #2
tinny commentedI created a patch which checks for empty entity.
Comment #3
danflanagan8I ran into this exact same problem with a site using moderation_sidebar and entity_hierarchy. Somehow node is
nullin some cases. I don't understand why, but sometimes this results in an ajax 404 instead of the gentler array_flip warning. This patch definitely fixes the error and life is good.Thanks!
Comment #4
larowlanAny way we can write a test for this?
Comment #5
acbramley commentedI think you could set up a test module with a route similar to this
Comment #7
larowlanDoesn't seem worth the effort for a two line change that only impacts people with this module.
Committed and rolling a 3.3.2 release