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.
When attempting to create content for nodes with file fields, if no previous data has been entered (Sucessfully) then the , chosen file storage directory does not exist. This produces errors such as
File temporary://filefield_HTNlWB.txt could not be copied, because the destination directory ..../sites/default/files/ is not configured correctly.
Comment | File | Size | Author |
---|---|---|---|
#6 | devel-create-tmp-dir-issue-1210300-6.patch | 1.94 KB | Alan D. |
#1 | devel.generate.file_.directory.create-1210300.patch | 710 bytes | arcticShadow |
Comments
Comment #1
arcticShadow CreditAttribution: arcticShadow commentedAttached a patch which fixes the issue for me.
Comment #2
salvisHave you tried configuring the directory?
Usually, Drupal creates it when you configure it, and it creates it with a .htaccess fiile that's needed.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedyeah, pretty sure this is a symptom of not setting up drupal's file storage. drupal already warns when you do that.
Comment #4
arcticShadow CreditAttribution: arcticShadow commentedThe thing is with this that for image field types, the directory is created on the fly, same location (different name of course) as files should be created.
Comparing the images generate script to the files generate script, Images has a create_directory_if_not_exist flag at the end of the move-generated-file command.
I'm relatively new to drupal and even newer to community contribution and patching, But I don't think devel_generate is meant to fail when creating files but succeed when creating images. in the scenario when neither node_image or node_files directories exists before the generate.
Comment #5
pavelsof CreditAttribution: pavelsof commentedI came across the same problem but manually creating some content beforehand seems to fix it nicely.
Comment #6
Alan D. CreditAttribution: Alan D. commentedThere still appears to be a couple of errors here (Note that the file directory IS being created in the latest DEV version):
The functions file_unmanaged_move() and file_move() expect the FILE_EXISTS_RENAME constants, but are getting the FILE_CREATE_DIRECTORY constants.
ie: the function is replacing the existing file if there is a conflict.
And this looks like it could need work to integrate with File entity (fieldable files) module. Currently, I get random errors about bundle IDs missing via an EntityMalformedException being thrown. This was due to conflicts in file_move() during generation via xxx_move(FILE_CREATE_DIRECTORY) issues addressed in the patch. If I come across this again, I report a new issue to the relevant queue and cross post.
Comment #7
hansrossel CreditAttribution: hansrossel commentedIn my case these errors were caused by the fact that I only allowed pdf as file extension for the filefield while devel_generate only generates txt files. So adding txt again as allowed extension for the filefields fixed it.
Comment #8
Alan D. CreditAttribution: Alan D. commentedThe latest dev version should work without any issues (hashed file name from memory - so very low chance of conflicts in the file names), however the changes above still apply.
Comment #9
salvisCan we close #1175142: Generating content failed with numerous notice and warning message as a duplicate of this?
@Alan D.: Are you saying that your patch is not needed anymore?
Comment #10
Alan D. CreditAttribution: Alan D. commentedNope, but it's a bug that has minimal chances of ever being hit. Correcting the usage of the File API really. Other related threads here already appear resolved and the point hansrossel raised appears to be a new issue (at least it appears different from initial points raised late last year in both threads).
Comment #11
salvisI'm a bit confused by this thread.
@arcticShadow:
Your patch in #1 adds FILE_CREATE_DIRECTORY to the file_move() call. FILE_CREATE_DIRECTORY is not among the constants that are allowed for file_move(), and I doubt, whether your interpretation is correct.
@Alan D. #6:
So we should have closed this issue as WAD and #6 should have gone into a new thread, right?
FILE_CREATE_DIRECTORY (1) is definitely the wrong constant for file_move(), the 1 means FILE_EXISTS_REPLACE, as you point out. Removing it makes it default to FILE_EXISTS_RENAME (0), which is probably what was intended.
I think we should commit #6.
Comment #13
acoustika CreditAttribution: acoustika commentedIm getting this error also..... With image field, and yes it seems like its because i have configured my public filesystem and the image field with a token....
For the particular image field I have a path like files/images/[User-uid]
And i can create conten manually but devel will not create directories on the fly in a situation like this it seems,
I have newest dev version of pretty much all on my site....
Comment #14
blackspiraldancer CreditAttribution: blackspiraldancer commentedSame situation here. I managed to make the error completely disappear removing all tokens inside the image file path, within the field configuration (that's obviously not the desired behavior).
Comment #15
Dave ReidThe parameters to file_move() have been fixed with #2429787: File generation should use file_unmanaged_move() instead of file_move() before the file object is saved