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.
We recently encountered this kind of notice. Seems like it's happening when media slideshow is used as entity reference via inline_entity_form. In our case have a "gallery" paragraph which has entity reference field to "slideshow" media bundle. On a node edit form we inline that paragraph. If we add gallery paragraph and then remove it right after, save the node, then this notice is encountered.
The problem happens on the line \Drupal\media_entity_slideshow\Plugin\MediaEntity\Type\slideshow_item:99
/** @var \Drupal\media_entity\MediaInterface $slideshow_item */
$slideshow_item = $this->entityTypeManager->getStorage('media')->load($media->{$source_field}->target_id);
if (!$slideshow_item) {
return $this->getDefaultThumbnail();
}
Because the source field contains value [0 => NULL] and that notice pops up.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3004389-3-fix-array-flip-notice.patch | 753 bytes | mbm80 |
| |||
#2 | 3004389-2-fix-array-flip-notice.patch | 717 bytes | hideaway |
Comments
Comment #2
hideaway CreditAttribution: hideaway at drunomics commentedNot sure if it's problem of media_entity_slideshow module, can be also on inline_entity_form side. Anyway, the following extra condition (which I hope does not do any harm) is fixing it for us.
Comment #3
mbm80 CreditAttribution: mbm80 at drunomics commentedRerolled for 2.x
Comment #4
chr.fritschThis is a problem of IEF I think because with the patch the deleted gallery will still be created.
Comment #5
chr.fritschI am going to commit this fix. It makes the world a bit better. We are also facing this issue when you try to save a media entity (slideshow) without any images (for example programmatically).
Comment #7
chr.fritschThank you