Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Running on the latest dev this happens. This is unexpected and is possibly a regression, and we need to introduce tests to ensure this works.
Comments
Comment #1
Devin Carlson CreditAttribution: Devin Carlson commentedI see the same behaviour with unstable7.
How should determining the file type of existing managed files be handled?
A batch process that does something like:
There has been some talk on IRC of exposing a button, i.e. "reclassify files", on a settings page which does something similar.
Comment #2
tchopshop CreditAttribution: tchopshop commentedI uninstalled and reinstalled File Entity and Media (to solve a persistent update issue: http://drupal.org/node/1901886) and now under admin/content/file the existing files are not showing any "type".
Also -- and possibly related, but most importantly -- all thumbnails are broken on admin/content/file/thumbnails and in the Media Library and on the node/edit page with a media field.
Comment #3
tchopshop CreditAttribution: tchopshop commentedShould I post my problem (see #2 above) in a different issue? Not sure it is related to this one. My main worry is that I have broken the link to all those images and won't be able to generate thumbnails for them. I can't figure out what to do.
Comment #4
Dave Reid@tchopshop: If you edit the raw records in file_managed to change type column values to image, does the problem resolve itself? If so, then yes, your issue is this one here.
Comment #5
eidoscomJust a note: If you edit a file and save, the file type is get ok.
I can remember other releases where once the module was installed, It has a need to update all the files to get the change from file to file entity ... I'm pretty sure of this but don't know exactly.
So it seems that the code to accomplish the function must be inside the module ... I revised the file_entity.install and found this:
It seems related to what we are getting here isn't? Perhaps this is not doing after install??
Comment #6
eidoscomI runed
UPDATE `file_managed` SET `type`=SUBSTRING_INDEX(filemime, '/', 1) WHERE 1
on Mysql and all image files are now ok, but not all the other files.Used this to convert all the pdf files of my site
UPDATE `file_managed` SET `type` = 'document' WHERE `filemime` = "application/pdf"
.Comment #7
eidoscomI can't understand exactly what code in #1, but I think that must get all the "type" values and the mimetypes associated in order to establish the correct "type" value for the file. I added a comment where this I think that must be.
An example is a pdf file where the mimetype is 'application/pdf' but the correct type string is 'document'.
Comment #8
Dave ReidI think what we'll probably need is a solution that:
Comment #9
Devin Carlson CreditAttribution: Devin Carlson commentedA patch to, during installation, find all managed files and queue them up for processing during cron runs. When cron runs, batches of files will be analyzed, have their file types determines (if possible) and saved.
Comment #11
Devin Carlson CreditAttribution: Devin Carlson commented#9: determine-file-file-types-during-install-1977662-9.patch queued for re-testing.
Comment #13
aaron CreditAttribution: aaron commented#9: determine-file-file-types-during-install-1977662-9.patch queued for re-testing.
Comment #14
Devin Carlson CreditAttribution: Devin Carlson commentedAn updated version of #9 which includes tests and drops
drupal_write_record()
in favour of a simply doing afile_save()
.Comment #16
Devin Carlson CreditAttribution: Devin Carlson commentedComment #17
aaron CreditAttribution: aaron commenteddoes not work if you uninstall/re-install the module.
Comment #18
Devin Carlson CreditAttribution: Devin Carlson commented@aaron, did you make sure to fully uninstall (not just disable) File entity in between your tests and run cron after each install of the module?
I'm not able to duplicate any problems after re-installing File entity.
Comment #19
jenlamptonI can confirm that uninstalling and re-installing file_entity and running cron does *not* update the 'undefined' file types.
(I'm using 7.x-2.0-unstable7 with this patch)
Comment #20
jenlamptonOkay, so things are different running 7.x-2.x-dev plus this patch. After uninstalling, reinstalling and running cron the files now have types.
* For those that follow, Please note that this patch will not work on the 7.x-2.0-unstable7 version.
Comment #21
Devin Carlson CreditAttribution: Devin Carlson commentedCommitted #14 to 7.x-2.x.
Comment #23
jenlamptonThanks @Devin Carlson!
I love it when I can delete lines from my PATCHES.txt files! :)
Comment #24
maxplus CreditAttribution: maxplus commentedThanks,
I needed to uninstall and re-install file entity but then on every cron run, several files changed from undefined to image.
Great
Comment #25
potassiumchloride CreditAttribution: potassiumchloride commentedIf you're like me and ran into undefined file types after installing Media module, wait for cron to run or go run cron manually (admin/config/system/cron) and the files will be categorized for you.