This patch provides support for exporting files for Drupal 7.
Since files are entities in Drupal 7, We need to take a bit of a different approach than in D6:
* This patch creates a new features category (Files), where you can export individual files. This was not the case in D6, where the files were only exported when they were they were part of an exported node. I think files deserve their own category since they can be fieldable when using file entity or media module.
* The patch provides support for file, image and media fields on nodes and automaticly adds the files to the feature when a node is selected.
Some other notes about the patch:
* Since it is hard to enforce a particular order in which items are imported, We might be in a situation where the node is created before the files has been created. To fix this, the patch contains code that checks if the file has been inserted, and if it hasn't, it invokes all default_files hooks and stores the file in the database if necessary.
Comments
Comment #1
fabsor commentedFixing title.
Comment #2
fabsor commentedDreditor pointed out that I missed a newline, so here is an updated patch.
Comment #3
ao2 commentedHi, I have just started to play with uuid_features after trying Default Content and I find that uuid_features takes a more generic approach.
Exporting files is a very useful addition indeed, but even with this patch applied we still need to copy the
files/dir manually right? I can't see actual files in the feature archive when I export their drupal representation.Thanks,
Antonio
Comment #4
fabsor commentedHi!
This module provides a drush command to move the files to a feature, drush ufuf. It can be used after the feature has been created.
Comment #5
ao2 commentedOK, so if I get it the workflow should be:
drush ufuf default_contentto copy the actual files in the directory of the feature abovedrush maketo rebuild the site after each feature is complete).This seems to work well with some minor glitches:
drush ufufwants to depend on filefield, I had to change that:But it is very promising, thanks @fabsor.
Comment #6
d.olaresko commentedthere is a little mistake in this patch:
function uuid_file_features_export.
must be
Comment #7
fabsor commentedSetting this issue to needs work as appropriate. I will work on this as soon as possible, if someone doesn't post a patch before me =)
Comment #8
nattsHi there - are you still working on this?
Comment #9
lotyrin commentedAttempt at a reroll without a deep understanding of the code, and accounting for #6
Comment #10
lotyrin commentedOops. And here's the file.
Comment #11
lotyrin commentedOops again, and this one also has the change from #5 to fix drush ufuf
Comment #12
lotyrin commented:( And here is a file with actual stuff in it.
Comment #13
lotyrin commentedDoesn't seem to actually work.
Comment #14
cinnamon commentedIt seems this patch is using obsolete uuid_file_find(), instead one could use this for example:
I'm sure it can be done prettier, but this works(tm)! It's however not the whole story:
- one should use the dev version of uuid_featrues
- apply patch from #12
- edit like shown above (replace all occurences of uuid_file_find that is
- in your feature choose recreate, and uncheck and recheck an entry under node(uuid), file entities should now be picked up
- save and deploy your updated feature
- run "drush uuid-features-update-files %your feature%"
You should now have a feature with embedded files to deploy on another install.
Hope this helps!
Comment #15
jrao commentedRerolled patch from #12 with changes suggested in #14
Comment #16
RAD-lance commentedShould I use drush for working this module now?
I need to export my cck imagefield content with my feature.
Comment #17
hswong3i commentedConfirm #15 able to apply to latest 7.x-1.x-dev together with following issues:
It is now applied to DruStack 7.x-23.x and I will detail confirm if it works as expected
Comment #18
hswong3i commentedComment #19
ergonlogicHi all,
Nice effort so far on this issue. Unfortunately, alone, the patch in #15 doesn't appear to work. While the file entity is recreated properly, the reference to it from within a node body is still pointing to the original Field ID:
When reverting the feature, it tries to revert the node first and then the file. So I tried reverting the file field first, then the node, but still no luck.
There's also a minor E_STRICT warning, but that's really just a coding style thing, and using a temporary variable clears it up:
Comment #20
jrao commentedRevised patch which added null checking to avoid errors when file doesn't exist.
@ergonlogic: The reason it doesn't work with reference in body is because of #2117453: uuid_node doesn't use entity_uuid_load/save to load/save node
Comment #21
discipolo commenteddidnt apply anymore so i rerolled
Comment #22
discipolo commentedhttp://www.php.net/manual/en/language.references.pass.php
to avoid strict php notices we should pass this as a variable since
The following things can be passed by reference:
Comment #23
chrisgross commentedThe newest dev version of this module no longer seems to export media field data in features. This worked just fine in alpha4.
Comment #24
ergonlogicRe-rolled the patch from #20 to apply against latest head.
Comment #25
chrisgross commented#24 still results in the following warning when viewing the feature:
Strict warning: Only variables should be passed by reference in uuid_file_features_export_render() (line 74 of /sites/all/modules/contrib/uuid_features/includes/uuid_file.features.inc).This also seems new:
Adding the files via "file" in features now works in bringing that actual files along, but images are still not being attached to nodes on feature revert. The feature is listed as overridden and wants to remove the image field value from itself because it is empty.
Update: This last part seems to be caused by the fid being inserted in my_feature.features.uuid_node.inc, which makes sense because the file in the feature does not have an fid associated with it. Removing this value and reverting the feature seems to work, so the patch should probably be altered to exclude this value, as the whole point of uuid is so that you don't need an fid. The errors are still present, though.
Comment #26
chrisgross commentedThe problem seems to be in uuid_node.features.inc:
uuid_features_file_field_export() is where the fid stripping occurs, but after this is done, uuid_entity_features_export_render puts them back in the $export variable. Is it safe to simply flip the order of these things? such as in:
I don't really know the full implications of this, but it seems to fix the problem. If this is not okay, then the fid stripping functionality needs to reproduced in uuid_entity_features_export_render. There's a lot going on here, and it seems that there might be some redundancy in the code.
Either that, or if these are two different options, there needs to be some logic to determine which to execute.
Comment #27
chrisgross commentedSo, I just discovered what seem to be hidden UUID Features settings which, combined with the file_entity module (which I was already using), seem to make all of these patches unnecessary, for the dev build of this module as of today. Simply making file entities exportable on admin/structure/features/uuid_features works just fine. no patches to uuid_features necessary. I may just be blind, but the only link I could find to that page is from admin/modules, which is why I didn't see it before and started trying all of these recent patches that seem to be doing nothing but breaking things and causing errors.
If anyone else is in the same boat, I recommend trying these settings and exporting them as well. Solved all my problems.
Comment #28
andypost+1 to #26, specific entities should go second
Comment #29
PascalAnimateur commentedRe-rolled #24 against latest -dev to include suggestion from #26.
Seems to work in my case...
Comment #30
PascalAnimateur commentedHrm.. doesn't seem to work against latest uuid / uuid_features with either the base64 / packaged files option.
Comment #31
PascalAnimateur commentedFirst part of the problem solved by fixing the check for exportable file types in includes/uuid_file_entity.features.inc
With this patch, I can see the files under "File Entity" section of the feature creation form, but the actual files are not included in the generated module when packaged in assets (it does get included as inline base64, but the module can get really big).
Getting closer...
Comment #33
PascalAnimateur commentedThis new patch works with packaged files in my case. More testing needed though...
Comment #34
socialnicheguru commentedconflicts with Usage filter for files
Which is a better approach?
Comment #35
socialnicheguru commentedComment #36
PascalAnimateur commentedMy previous patch had a problem with missing files in the assets folder, as only the last file would be included.
This is an updated version of this patch, which doesn't address the conflict mentioned by @SocialNicheGuru.
Comment #37
danielvezaUsing the patch in #36 was fantastic! Solved my issue perfectly.
Comment #38
dimaro commentedComment #41
zipymonkey commentedNot sure if this is the right place for this but I've modified the patch in exclude the user_uuid from the file_entity export. This is causing my feature to always appear overridden when deployed to a different site or environment.
Comment #42
zipymonkey commented#41. This does not fix the issue I'm having.
Comment #43
nelsongrin commentedPatch #36 works perfectly!
Comment #44
nelsongrin commentedProvided new patch to fix coding standard issues based on patch #36.
Comment #45
nelsongrin commentedThe following issue Fatal error: Class 'ServicesWebTestCase' not found when visiting drupal testing page Primary tabs View(active tab) will fix the problem with tests failure.
Comment #46
nelsongrin commentedComment #47
nelsongrin commented