When you add a new media type whilst Crop API is installed, you get this pesky error message:

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

This is due to Crop API calling $bundle->id() in crop_form_media_bundle_form_alter() -- the bundle has not been created yet, so it has no ID. Therefore, NULL is passed into the entity storage system, where it wreaks minor, but annoying, havoc.

Proposed Resolution

Crop API should only try to alter the media bundle edit form, which guarantees that the bundle has been saved and has an ID.

CommentFileSizeAuthor
#2 2904514-2.patch721 bytesphenaproxima
#2 2904514-2.png65.4 KBphenaproxima

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Status: Active » Needs review
StatusFileSize
new65.4 KB
new721 bytes

Here is a screenshot of the error, and a patch that fixes it. Not sure what else this needs before it can be committed...?

phenaproxima’s picture

Issue summary: View changes
woprrr’s picture

Status: Needs review » Reviewed & tested by the community

Look good to me

Thank a lot @phenaproxima

During this review I have seen some changes needed for 8.4 !! I count on you for follow next patches :) AGAIN sorry for delay :O

This patch need to be deploy on 1.x and 2.x

phenaproxima’s picture

Should we land this patch in the 8.x-1.x branch (Media Entity-compatible), then have a follow-up issue to port the same changes into 8.x-2.x? That might be the cleanest way to go...

woprrr’s picture

Yes, you right at the beginin I will try to make all changes in that issue but I've found somes fixes and I have created #2918441: Make Crop API compatible with core Media to assume theses changes.

This patch does merged only in 1.x branch

  • woprrr committed 71eea5f on 8.x-1.x authored by phenaproxima
    Issue #2904514 by phenaproxima, woprrr: Crop API causes an error when...
phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, @woprrr!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.