Closed (fixed)
Project:
D7 Media
Version:
7.x-1.0-rc3
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Sep 2011 at 01:35 UTC
Updated:
28 Oct 2012 at 21:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
dave reidThere should be no empty bundle strings in File entity 7.x-1.x. What would cause this?
Comment #2
dave reidAs a clarification we add a file type if it is not set in hook_file_presave(), we have an update function that should cover any files that were uploaded prior to file_entity, and the default if the file type is undetermined is 'application/octet-stream'.
Comment #3
chx commentedAlso note that if the type is undetermined then my patch is still not adequate -- there needs to be a fallbakc for undefined.
And the problem is with media, not file_entity. Moving there. Despite what effulgentsia said this patch is against the latest 7.x-1.x ( http://drupalcode.org/project/media.git/blob/refs/heads/7.x-1.x:/file_en... ) which doesnt http://drupalcode.org/project/media.git/blob/refs/heads/7.x-1.x:/file_en... have an update function to supply type. Should we backport that from file_entity, then, instead?
Comment #4
chx commentedYes, http://drupalcode.org/project/file_entity.git/blob/refs/heads/7.x-1.x:/f... this looks good.
Comment #5
effulgentsia commentedI'm about to be on vacation for a week, so won't be able to see this through during that time. If people find solutions that work for them, that's great, so for anyone interested, please keep this issue and/or #1266620: Missing bundle property on entity of type file error going as you see fit.
A difference between Media 1.x and 2.x though is that in 1.x, it's the Media module that has some legacy logic for determining the type of a file, and in 2.x, that has been moved upstream to the File Entity module. I'm a little hazy right now on how to best adjust Media 1.x to match the requirement of no empty type. There's a couple issues to consider, but nothing I can coherently express right now. Anyway, I encourage people to experiment as needed, or else apply #1067750-49: Let Field API fail in a tale-telling way on invalid $entity to your local core installations as a stop-gap.
Comment #6
Starminder commented+1
Comment #7
dave reidYeah the problem here is that the logic to determine what type of file it is isn't based on mimetype - its based on file_get_type() which can return a NULL value. I think this is part of a larger problem that we could fix in 7.x-2.x properly but is wound up in legacy code in 7.x-1.x.
Comment #8
dave reidThinking...what if we added something like this:
Comment #9
chx commented#8 that's what #3 said Also note that if the type is undetermined then my patch is still not adequate -- there needs to be a fallbakc for undefined.
Just make sure it's not something that's defined as a bundle. I think 'undefined' works better than 'file'.
Comment #10
dave reidThe default bundle string for entities with no bundle is the entity type itself (e.g. bundle for user entities is 'user'), so that's why I went with 'file'. Also we'd need to ensure that we're not saving 'file' as {file_managed}.type when calling file_save() so that we get a chance to save the proper file type (tl;dr we need to adjust file_entity_file_presave() to check if $file->type == 'undefined').
Comment #11
j.slemmer commentedsub...
Comment #12
Starminder commentedAny ideas? I can't seem to disable media module, I have a field using it. Just had this happen trying to rebuild content access perms.
An error has occurred.
Please continue to the error page
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=469&op=do StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7389 of /home/hoslot5/public_html/includes/common.inc).
The content access permissions have not been properly rebuilt.
So, my site is kind of toast for anonymous users. I'm open to quick and dirty suggestions for now :) Thanks!!
Comment #13
femrich commentedSeems I am in the same position as Starminder--rebuilt permissions, got the same error, and now when I try to uninstall media modules I get a timeout error--only situation in which that seems to happen at the moment on my site. Watching for solutions...
Comment #14
femrich commentedAfter unsuccessfully trying patching, I have resolved this temporarily by reverting to drupal 7.7. Will watch for updates to core and relevant modules...
Comment #15
thomas bosviel commentedSubscribe
Comment #16
Starminder commentedApplied the one-liner patch from here: http://drupal.org/node/1266620 and it solved my permissions issue.
Comment #17
dave reid.
Comment #18
dave reidComment #19
effulgentsia commentedThis solves it as far as I know. If anyone finds a use-case that it doesn't handle, please comment. Thanks.
Comment #20
JacobSingh commentedTo summarize and make sure I got this straight. The goal here is just to stop using an empty string for an undefined media type and start using FILE_TYPE_NONE, right?
Do you think this might cause more confusion then just having something unique?
How will this handle files which are already in someones' DB which have no type? won't they be in limbo forever?
Comment #21
JacobSingh commentedComment #22
dave reidAs a follow-up (or included here) we should patch file_entity to use a proper menu loader for bundle menu items (e.g. %file_type_load rather than using just '%' in the menu paths).
Comment #23
chx commentedFILE_TYPE_NONE is a good constant but the value really should be just file or something but not und. und is from the ISO 639-2 standard for undetermined language you can't just that for a file.
Comment #24
JacobSingh commented@chx: I didn't love this, but tbh, it's only going to last in 1.x and is already replaced in 2.x (which everyone will be upgrading to as soon as possible). So it's really not a huge deal. Do you have another suggestion?
Comment #25
chx commentedWe have agreed on 'undefined' on IRC quickly
Comment #26
effulgentsia commentedThanks for the reviews. This addresses #22 and #23.
Comment #27
becw commentedReviewing.
Comment #28
effulgentsia commentedI don't know if there's any situation in which hook_schema_alter() can be called without the .module file loaded, but in case there is, this patches uses the literal instead of the constant here.
Comment #29
effulgentsia commentedsorry. didn't mean to unassign becw.
Comment #30
becw commentedThis patch looks good to me. Tests run, the update function runs, and the code looks fine. RTBC for 7.x-1.x
As far as I can tell from the discussion above, undefined file types are already handled in 7.x-2.x and the independent File Entity module. We should still add the update function (
file_entity_update_7002()) to the independent File Entity module.Comment #31
becw commentedComment #32
effulgentsia commentedWoohoo! Committed to 7.x-1.x.
Comment #33
Carlos Miranda Levy commented#28: media-file-type-und-1268378-28.patch queued for re-testing.
Comment #35
dave reidPlease don't do that for fixed issues.
Comment #37
jerrac commentedI'm using Media 7.x-1.x-dev released on 2011-Oct-16. As well as the bundled File Entity module. Even though the patch from #28 is committed, I still get this error when browsing admin/content:
Dave Reid said that http://drupal.org/node/1266620 is a duplicate of this issue, which is why I'm posting here instead of there.
I'm on Drupal 7.8.
I tried upgrading to 7.x-dev, but it didn't seem to do anything.
I tried running admin/config/media/rebuild_types.
When I first enabled File Entity, it gave me this error:
Does that have something to do with it? That error never showed up again, and File Entity stayed enabled. So I think it's installed fine.
I had Styles installed and enabled, but I've disabled all it's modules and uninstalled them.
That's everything I can think of right now. Is there any other information I can post that would help? Or steps I can take?
Comment #38
ezeedub commentedNot sure about the new title/status, etc..
I just got this error earlier today upgrading D6 to D7...
Just to be sure, I ran the upgrade a second time without relying on drush's automatic downloading and enabling of required modules.
Drupal 7.10, Media 1.0-rc2. Looks like I've got the patch in #28 (just in case I tried with 1.x-dev, same error).
Did this get re-introduced somehow or is this a different bug? Thx.
Comment #39
ajeancharles commentedI manually made the updates to the media module. I am not getting that error any more.
I want to submit my changes, however I don't quite grasp the process. It seems very opaque and more complicated than necessary.
Anybody interested in my version, to upload or what not is welcome to it.
I have attached the fixed module below.
If someone can show me the in's and out's in doing some of the maintenance, i will certainly help.
Regards
Comment #40
bryancasler commentedGot these notices on a fresh install...
Comment #41
volocuga commentedSame here, using latest dev of 7.1 branch
Can not even enable the module
Comment #42
Taxoman commented#41: which Drupal version was that against? (interesting, now that 7.11 and 7.12 was just released)
Comment #43
volocuga commented@Taxoman: just updated to d 7.12 The error still here
Comment #44
David_Rothstein commentedIt seems unlikely that any remaining errors are due to empty file types, which is the original topic of this issue. Or at least, no one has provided any evidence that they are.
Therefore, I'm closing this again; if anyone can debug this to the point where they can prove that it is actually due to an empty file type, feel free to reopen; otherwise, the bug you're encountering is most likely some other issue. For example, I've encountered some EntityMalformedException errors as well, but it's not due to this issue; rather, it's due to #1426820: Fix Notices and EntityMalformedException if FID is not in the file_managed database table which is different.
Regarding @animelion's comment in #40 (about PHP notices due to undefined FILE_TYPE_NONE), that constant is defined by the File Entity module which is a dependency of Media, so it's hard to see how that can happen unless something went wrong and somehow the File Entity module never got enabled? If that is reproducible, it should be filed as a separate issue, though, rather than here.
Comment #45
camdarley commented@animelion in comment#40: I fixed this issue here: http://drupal.org/node/1450260
Comment #46
hongpong commentedThis may be a tangent but if you have malformed files entities - see #1446440: Unable to view me media management pages (EntityMalformedException: Missing bundle property...) for my one-off SQL fix for column type in the files_managed table. Seems like some checker could fix this.
Comment #47
saltednutUnsure if this will help anyone else but I was having trouble with this. It turns out either myself or drush did a poor job picking dependencies.
The site has file_entity 2.x under sites/all/modules/file_entity - but it also had media 1.x and file_entity 1.x under sites/all/modules/media/file_entity
Removing the file_entity 2.x caused numerous errors - so it looks like this is the one that was enabled.
I replaced the 1.x media with 2.x unstable and it seems to have solved my errors. It initially threw a nice bit of exceptions about the old instances of file_entity 1.x - so maybe both were considered enabled? Strange.
I was able to clear cache and those errors went away though.
Running update.php did a few install hooks. Seems to be working now using media 2.x / file_entity 2.x with no reported issues.
In short: make sure you don't download the wrong version of file_entity and mix-match accidentally. The modules page might even report using 1.x but if there are two versions of file_entity floating around, you will see bogus errors like the one reported in #1.
Comment #48
ressaI got this error after executing
drush dl media wysiwyganddrush en -y media wysiwyg:The installation didn't go through, there was no 'Wysiwyg profiles' menu point under 'Configuration' > 'Content authoring'. Uninstalling and reinstalling the Media module fixed it, and the Wysiwyg now works.
Module versions
Entity: 7.x-1.0-rc3
Media: 7.x-1.2
Wysiwyg: 7.x-2.2