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.
I had this module enabled on a project where I was trying to get core media working I ran into a problem that the entity 'media_bundle' could not be loaded. Digging a bit deeper I found that this module was trying to load that bundle with the following code
$entity = $form_state->getFormObject()->getEntity();$bundle = $entity->bundle();
$entity_type = entity_load($type, $bundle);
And that confused me a little cause the entity is clearly from the type 'media' but the 'media_bundle' wasn't defined anywhere as far as I know except that this module makes some assumptions about it.
elseif ($info['base_form_id'] === 'media_form') {$type = 'media_bundle';
}
.... and ....
elseif ($info['base_form_id'] === 'media_form') {
$type = 'media_bundle';
$route = 'media';
}
Can you please shine some light on it?
Comment | File | Size | Author |
---|---|---|---|
#7 | support-core-media-module-2917605-7.patch | 3.16 KB | dqd |
Comments
Comment #2
villette CreditAttribution: villette commentedI have the same error, it is caused by the fact that the entity defining the media type is called "media_type" in the core module whereas its name is "media_bundle" in the media_entity contrib module.
It means that this module does not support core media module, or partially. I haven't reviewed all the code of the module but I made a patch that answers this exact need. Maybe it would be necessary to check if there are some other places in the code to adapt.
I'm renaming this issue to encompass a larger scale.
Comment #3
iampumaCurrently this module is broken with Drupal >= 8.5. As from there media has been added to core.
Reproduce by:
- Install vanilla Drupal
- Enable media
- Enable entity_redirect
- Observe error on /media/add/image
Setting this issue to bug report and priority to major as it breaks part of the site .
Comment #4
thejimbirch CreditAttribution: thejimbirch at Kanopi Studios commentedThe error message is "The "media_bundle" entity type does not exist." when trying to edit a Media item.
The patch in #2 fixes this issue. Thanks @villette ! Thanks @Rene Bakx for posting!
Comment #5
dqdApplying the patch removes the first error when /media/add/image gets called first time, but it seems that there is one more spot where this needs to be fixed. Saving and publishing the added media causes still the same error after patch has been applied. But the files have been saved.
Running
grep -rnw ./ -e media_bundle
in module folder shows me a second place which needs to be fixed.Comment #6
dqdFirst attempt to add issue fix on line 148 and 230 ...
Comment #7
dqdOooops, mixed lines (if/else) ... wrong wrapping. again.
Comment #8
dqdTesting ... I can confirm error disappears on all instances of add > upload > save forms and redirects. Patch tested on 1.4 and latest dev for further release management.
Comment #10
NickDickinsonWildegit commit -m 'Issue #2917605 by diqidoq, villette, Rene Bakx, iampuma, thejimbirch: Support core media module' --author="Digidog "