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.
this patch corresponds with the patch for file entity over #1292382: Make it possible to create any number of custom File Types - it will allow files to be viewed, because without this patch you get a WSOD when applying the other patch.
It is also removing a bunch of crud that we don't need any more, related to the file types.
Note that the patch is still in progress; I will update this issue with the final version when I have that done. I am just starting this issue so that it is in place, and so that people can start testing before it's done.
The patch is forthcoming.
Comments
Comment #1
aaron CreditAttribution: aaron commentedand here we go
Comment #2
aaron CreditAttribution: aaron commentedComment #3
paulmckibbenThe patch applies cleanly. Works great for me, combined with the file_entity patch at http://drupal.org/node/1292382#comment-5771928
Comment #4
paulmckibbenMarking this RTBC based on irc conversation.
Comment #5
aaron CreditAttribution: aaron commentedactually, this needs a little bit more work
Comment #6
aaron CreditAttribution: aaron commentedThis gets us a little bit farther. However, we need to do some more work in media_update_7203(), specifically in converting old media types.
Comment #7
tsvenson CreditAttribution: tsvenson commentedI get the following error when applying patch in #6 on a current 2.x dev and running the update.php. I'm testing this patch in combination with patch in #62 0f the #1292382: Make it possible to create any number of custom File Types issue:
It did 2 updates to the File Entity module, but this one for Media simply wont go through. I have tried re-running update.php and then its only the above update left, but it still fails.
Comment #8
tsvenson CreditAttribution: tsvenson commentedOki, done some more testing. This time on a new installation with this and #1292382: Make it possible to create any number of custom File Types applied before installing the site. Installation went fine without any errors, but I get another PDOException when trying to edit a field after setting the widget type to Media file selector.
Steps to reproduce:
It is possible to switch back to the Image widget and then access the Edit page again. So clearly something is going wrong in this patch.
Comment #9
dddave CreditAttribution: dddave commentedThis is already fairly old. Has the development in the meantime made this superfluous?
Comment #10
ParisLiakos CreditAttribution: ParisLiakos commented#6: remove-media-types-crud-1496624-6.patch queued for re-testing.
Comment #11
ParisLiakos CreditAttribution: ParisLiakos commentedi think we can just delete media.types.inc
this needs quite some work yet, but we should definitely make it happen before next unstable release
Comment #12
ParisLiakos CreditAttribution: ParisLiakos commentedOk this is pretty much ready :) removes quite some cruft
Just need some help here
feel free, regex is not my thing
Comment #13
ParisLiakos CreditAttribution: ParisLiakos commentedrerolled
Comment #14
ParisLiakos CreditAttribution: ParisLiakos commentedper #12
Comment #15
ParisLiakos CreditAttribution: ParisLiakos commentedAfter talking with dave in IRC, there is no need to remove update functions and force users to update to latest 1.x version before going to 2.x
here is the patch.
still needs #12 to be resolved
Comment #16
ParisLiakos CreditAttribution: ParisLiakos commentedok and this is the complete patch..turned out to be simple.
please rtbc, without this all installations prior to latest devs are broken
Comment #17
ParisLiakos CreditAttribution: ParisLiakos commentedOther media type is causing problems with this approach.
copy-paste from irc:
in file_entity there is no "weight" field like media types had..and because other type was matching all the elements, now when you upload a new file, whatever mimetype that is, it gets the "other" type instead of image
Another approach, see #1808902: Broken / incorrect file types after recent upgrade, credits @mrfelton
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commented.....and complete patch:
Comment #19
Devin Carlson CreditAttribution: Devin Carlson commentedMarked #1813300: File Type undefined as a duplicate.
Comment #20
ParisLiakos CreditAttribution: ParisLiakos commentedOk i removed media type crud code, but we still need the upgrade path.
Updated patches of #16 and #18 with the two different approaches..much more easier to review now:
Comment #21
ParisLiakos CreditAttribution: ParisLiakos commentedoops, wrong component
Comment #22
Rob_Feature CreditAttribution: Rob_Feature commentedI'd be willing to test this but don't really understand the two patches..are they alternate/different approaches to doing the same thing? Do I only apply one of them?
Comment #23
ParisLiakos CreditAttribution: ParisLiakos commentedYes.
First patch migrates old media types to file entity types, but "Other" media type screws everything because file_entity types do not have weight to make it apply last.
Second patch just drops the media_type table without migrating media_types and just updates existing files (their type property) to the new file_entity default types.
If we go with the first way we would definitely need a separate rule for "Other" media type. ie, dont migrate it at all.
If we go with the second we need to check if there is any other type besides the default media types that shipped with media (which i really doubt. does any module provide anything like that? i think no)
So in my opinion second way is the way to go
Comment #24
Kazanir CreditAttribution: Kazanir commentedI saw this node in the commit history and didn't realize you had only committed the patch in #18 to .dev. I'll apply the second variant and test it presently.
Comment #25
ParisLiakos CreditAttribution: ParisLiakos commentedUpdated patches
Comment #26
ParisLiakos CreditAttribution: ParisLiakos commentedYeah second was the old one
Comment #27
martins.bertins CreditAttribution: martins.bertins commentedI used the second variant together with latest dev version of module and it worked fine for me (fixed this problem http://drupal.org/node/1792738#comment-6618934). Got the result I was expecting.
Thanks for the good work!
Comment #28
Rob_Feature CreditAttribution: Rob_Feature commentedApplied the second patch and it updated all my types except for some Vimeo videos...they're still 'undefined'I also just added a new youtube video and it's type was "undefined" as well....so new content is also having the same problem? (I realize this isn't part of this 'update' issue, but it sheds light on maybe why the patch didnt work for me)It looks like this was my issue with the patch, so ignore my objection but please re-review with functional offsite videos: #1812976: Register video/youtube mimetype and provide an upgrade path
Comment #29
Rob_Feature CreditAttribution: Rob_Feature commentedswitching back to 'needs review' since after the patch from the issue I listed in #28, this update action worked across the board.
Comment #30
paulmckibbenI had to modify the update number from 7207 to 7208 since there is now a 7207 in the git repo. Rerolled the patch and attached.
The good news: when I tested this patch on a site that was on unstable6, with over 5000 files, including images, audio, video, and documents, the update was successful!
Should probably have one more reviewer, but I think this is RTBC.
Comment #31
Kpolymorphic CreditAttribution: Kpolymorphic commentedI tested this patch and the upgrade worked well
Comment #32
ParisLiakos CreditAttribution: ParisLiakos commentedNew patch that merges old mimetypes to new mimetypes as well
Comment #33
ParisLiakos CreditAttribution: ParisLiakos commenteddidnt test it yet btw
Comment #34
Kpolymorphic CreditAttribution: Kpolymorphic commentedBased on my review, I think that regardless of the mimetype mapping solution, an error condition exists for a failed mapping. The update should probably fail (because this type of update is not re-runable due to the table delete) or at the very least return an error in that case.
Comment #35
Kpolymorphic CreditAttribution: Kpolymorphic commentedsorry, did not mean to change the status
Comment #36
ParisLiakos CreditAttribution: ParisLiakos commentedOk..i searched a bit more...and docx not appearing as correct filetypes is not in the scope of this patch...There is not even a file type for application in {media_type} table which gets dropped..
Can you confirm that before upgrade there is no application type entry, so i commit this?
Comment #37
paulmckibbenYou're correct, there's no file type for application in {media_type}. However, other files (mainly pdf) get converted from application to document, and these should too.
That said, the issue may actually be elsewhere (in file entity, perhaps?) and have nothing to do with this patch. The mime type that failed was for a MS Word file with extension .docx. The mime type itself was:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
I see that file_type_get_enabled_types() does not return the "application/vnd.openxmlformats*" types. For "document", it only returns:
If you look at includes/file_mime_types.inc, there are A LOT more application/xxx mimetypes, none of which are returned by the above function. I think that is the root of this problem. Where would be the appropriate place to file an issue? Is this File Entity?
So anyway, I agree it has nothing to do with this patch. Why I marked it as "needs work": as kpolymorphic wrote in #34, there is no error message when there is a failure to map a file, and there probably should be. Make the failure visible, and that should allow this fix to be RTBC.
Thanks for your excellent work!
Comment #38
ParisLiakos CreditAttribution: ParisLiakos commentedsorry i missed this..like a drupal_set_message you mean?
i am planning to add an update function to file_entity for documents types before unstable7, that include all application/* mimetypes so yeah it should be fixed there
Comment #39
paulmckibbenSince it is an implementation of hook_update_N, if you return a string, that string will be displayed to the user on the update result page. It will also get displayed if the user uses drush to update the database.
So you could build an array of error message strings, implode it with PHP_EOL, and return it.
Great news that the missing mime types will be fixed in file_entity.
Cheers!
Comment #40
ParisLiakos CreditAttribution: ParisLiakos commentedOk, great thanks for explaining:)
Gave it a more thought and decided that this application => document is a media thing afterall..so here is a new patch..includes two update functions..once migrates types and fixes document the other updates fuiles and returns a list of the failing in the end:)
I think this is so much better now...thanks for the help all!
Comment #41
ParisLiakos CreditAttribution: ParisLiakos commentedThis patch turns failed file types to FILE_TYPE_NONE, so any module (eg media_youtube) can update those files without scanning the whole table again..
just using
WHERE type = 'undefined'
in its query.Will try this patch now on a site with 11k files..If it works then i will try on it the #1349058: Convert 'Media' fields to 'File' fields that use the 'Media file selector' widget..if both goes well i will commit them and then release unstable7..
i think its about time
Comment #42
ParisLiakos CreditAttribution: ParisLiakos commentedcommited with some fixes on comments and return text.
see here http://drupalcode.org/project/media.git/commit/1233117
Thanks for the testing all!
Comment #43
paulmckibbenUh oh...
I pulled the latest file_entity and media from 7.x-2.x git. Updating from unstable6 failed for me. Here's the output from drush updb:
It looks like the issue is with update 7201 in file_entity.install, so I'll write up a new issue in file_entity.
Comment #44
paulmckibbenActually, looking at it further, the problem is that file_entity_update_7201 had not been run yet. This is a new area for me, but I think you can use hook_update_dependencies (http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...) to specify that update 7208 in media depends on update 7201 in file_entity.
I'd try to roll and test a patch, but don't have time right now due to family events today. If somebody else is not able to look into it and I can squeeze it in tomorrow, I'll see if I can roll another patch to media.install to check for that dependency. But in the meantime I thought I'd post what I figured out so far and see if somebody else has time to run with it.
Comment #45
ParisLiakos CreditAttribution: ParisLiakos commentedThanks paul!
I made media update 7208 dependent on file_entity 7201
Have a nice time to day:)
thats what i committed
http://drupalcode.org/project/media.git/blobdiff/c1804b9ba76210ecdc929b3...
Comment #46
paulmckibben@rootatwc, thanks for all your hard work.
Unfortunately, I found another issue. This time, videos are getting set to "undefined". Again, I'm upgrading from unstable6 to the latest from the git 7.x-2.x branch.
This site is using media_brightcove 7.x-3.4 and media_youtube 7.x-1.0-beta2, if it makes a difference.
Before update:
After update:
Thanks,
Paul
Comment #47
ParisLiakos CreditAttribution: ParisLiakos commentedYeap.
For youtube videos try running the update with latest 2.x dev (see #1812976: Register video/youtube mimetype and provide an upgrade path)
media_brightcove needs to catchup as well...which project is is? http://drupal.org/project/media_brightcove only has 6.x versions
Those mimetypes are not provided by media module so these modules will have to provide upgrade paths
Comment #48
paulmckibbenThanks!
To answer your question, the brightcove project is actually just "brightcove" - http://drupal.org/project/brightcove. (I had mis-named the project in my earlier comment.)
Comment #49
InTheLyonsDen CreditAttribution: InTheLyonsDen commentedFYI - I just downloaded the latest dev versions of Media and FIle Entity on a fresh install and tried to enable Media and have it enable File Entity as a dependency and it failed with
I then enabled File Entity first, then was successfully able to enable Media.
You may have a problem with the install process.
Comment #50
ParisLiakos CreditAttribution: ParisLiakos commentedthanks for the headsup
see here #1749252: Add check for File entity 2.x to installation requirements
Comment #51
beeradb CreditAttribution: beeradb commentedWhen testing the upgrade path for the panopoly distro we ran into an issue with update 7208 which was introduced in this patch. The issue is the assumption of the media_type table existing. However, the media_type table isn't defined in media_schema, but rather is introduced in media_update_7002. Perhaps it was originally in media_schema but has since been removed. When the table doesn't exist it causes the update to break, and subsequent updates aren't ran.
The following patch just does a db_table_exists check on the media_type table before doing the heavy lifting in 7208.
Comment #52
ParisLiakos CreditAttribution: ParisLiakos commentedI guess if this table does not exist then we could just return
Comment #53
ParisLiakos CreditAttribution: ParisLiakos commentedJust commited a check in the start of the update. if table does not exist it returns
Comment #54
midmood CreditAttribution: midmood commentedYesterday i solved this problem updating media, media_youtube and media_vimeo to the latest devs.
Since then I have the problem described in this thread, specifically in my comment:
http://drupal.org/node/973202#comment-6761304
Comment #55
midmood CreditAttribution: midmood commentedYesterday i solved this problem updating media, media_youtube and media_vimeo to the latest devs.
Since then I have the problem described in this thread, specifically in my comment:
http://drupal.org/node/973202#comment-6761304
Any chance these could be related?
Comment #56.0
(not verified) CreditAttribution: commented...converted the link to the issue to a [#???]