Closed (outdated)
Project:
Feeds
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Jun 2015 at 14:00 UTC
Updated:
9 Feb 2026 at 19:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
megachrizSounds like this would solve #2409075: Did not delete temporary file "public://personals/personpic/110623-9611.jpg" during garbage collection, because it is in use by the following modules: file..
Did you notice the error reported in that issue in your log?
Comment #2
ucaka commentedNo logs unfortunately. I found the issue because of a permission problems on the file fields with private file system. So not enough time for a cron run.
It seems to me that the related issue is caused exactly by the reported problem. Drupal tries to delete the files because of the temporary status in file_managed but it's stopped by the file_usage table.
Comment #3
twistor commentedIs this happening with a local file, or a remote file? Remote files are saved with file_save_data() which sets the status automatically.
Comment #4
megachrizOn a website where I encountered this issue, it's about a local file. Actually, I wrote an alternative file mapper for that website that produces a file out of a base64 encoded string, saves that in the file temporary directory and then passes the file url of the result to
file_feeds_set_target(). The website in question is running 7.x-2.0-alpha8+71-dev (January 16, 2015), so I'll have to recheck with the latest dev.Sample code of the mapper:
Comment #5
twistor commentedI don't think setting the status on the field has any effect, unless I'm missing something.
Comment #6
twistor commentedComment #7
twistor commentedComment #8
twistor commentedHmm, that's not the issue.
file_field_presave() and image_field_presave() both set the status to permanent automatically.
Comment #9
megachrizMarked #2547265: "fail" to import to private:// as a duplicate.
Summary of that issue:
0. Might have the same cause or hint to a possible cause of this issue.file_field_presave()andimage_field_presave()set the file status toFILE_STATUS_PERMANENT(which equals to 1, see /includes/file.inc).The process for trying to find the cause of the issue is:
Comment #10
kumkum29 commented@MegaChriz
I did several tests with different configurations.
Without the "Enable File (Field) Paths" option on the field image > No problem
Case 1: single image > uid = 0 & status = 1
Case 2: single image + rewrite path with Feeds Tamper > uid = 0 & status = 1
Case 3: multiple images > uid = 0 & status = 1
Case 4: multiple images + rewrite paths with Feeds Tamper > uid = 0 & status = 1
With the "Enable File (Field) Paths" option, and if I specify a specific destination for the images > Problem
Case 1: single image > uid = 0 & status = 0
Case 2: single image + rewrite path with Feeds Tamper > uid = 0 & status = 0
Case 3: multiple images > uid = 0 & status = 0
Case 4: multiple images + rewrite paths with Feeds Tamper > uid = 0 & status = 0
For me, the problem comes from the File (Field) Paths module. (or an incompatibility betwenn Feeds & File (Field) Paths)
Comment #11
megachriz@kumkum29
Ah, this is useful. So my suspicion that File (Field) Paths might have something to do with the issue appears to be right. Did you try to reproduce the issue on a clean install as well (as I said in #9 I wasn't able to reproduce it yet on a clean install)? Can you give an example of what you mean with "a specific destination"? Is it a folder with or without use of tokens? Or is it just renaming a file using tokens?
Comment #12
kumkum29 commented@MegaChriz
In the "File path" setting I have specified a specific directory ("images") and for the file name I use the default tokens: [file:ffp-name-only-original].[file:ffp-extension-original]. On another site, I get the warnings (in logs) with a specific directory (with tokens), and with tokens in the field name.
In all cases, I get always 0 for the uid in the file_managed table of db.
Comment #13
megachrizStill have no success to reproduce this on a clean install, even with File (Field) Paths enabled and directory set to 'images' :(.
I did notice an interesting difference regarding 'uid'. When importing using the UI (and logged in as user 1), the owner of the imported files becomes '1'. But when not logged in, and trigger the import either via cron or drush, the owner of the imported files becomes '0'.
@kumkum29
How did you trigger the import?
Comment #14
kumkum29 commentedHello MegaChriz,
I reopen this old subject, after having make new tests. I did notice the same behavior during the importation. If we use the UI, the owner of the imported files is 1. But if the importation is making with cron, we get 0 in the uid value.
Perhaps this is a starting point to find the solution?
Comment #15
megachrizI think I found the cause of the bug! And the bug seems to only be exposed when filefield_paths is enabled.
See the following line in feeds/mappers/file.inc (± line 187):
This results into the value on the field to become something like this:
Note the status value.
When uploading a file using a node edit form, the field value looks something like this:
When filefield_paths is not enabled, this doesn't cause any direct issues. But when it is enabled, then filefield_paths uses the data on the field to build a new file (filefield_paths/modules/filefield_paths.inc, ± line 104, function
filefield_paths_filefield_paths_process_file()):filefield_paths casts the data on the field to an object.
Before the code from filefield_paths is executed, the file's status gets set to permanent via
file_field_presave()orimage_field_presave(), but the status value on the field stays the same:0. Since filefield_paths uses the data on the field, the file gets the status 0.What I think that Feeds should do is only save the values relevant for the field instead of casting a file object to an array. See attached patch.
I'm still not sure why I am not able to reproduce the issue on a clean install though, but it probably matters what happens in
FeedsEnclosure::getFile. In my case, the line$file = file_copy($file, $destination, $replace);gets executed.Comment #17
megachrizHm, the tests are broken caused by this issue in Drupal core: #1621356: Pass all the parameters of hook_options_list() to options_list_callback.
Note to myself: calling
taxonomy_allowed_values()was added in #1019688: Taxonomy mapper options: term name +tid, term name, tid, guid (avoids mapping error for Numeric taxonomy term, too).Comment #18
kumkum29 commented@MegaChriz
I'm happy to see that the problem seems to be identified. I'm not a good developer to help you to resolve this issue with a code. But I can test your patch and follow this issue.
Comment #19
megachriz@kumkum29
It would be great if you want to test the patch in #15! I see with the information I have now if I can reproduce the issue on a clean install. This way I perhaps could create an automated test for the bug.
Comment #20
kumkum29 commented@MegaChriz
I have tested your patch #15:1- In the "file_managed" table, the new files have "0" for the "uid" & "status" columns.2- I get another problem with this patch. The files seems to be duplicated in the root of files directory (filename with a "0", e.g. myimage_0.jpg) , before that the "filefield paths" rename & move the files in the good directory.
I badly patched the module. I do a test again. Sorry....I have tested your patch #15:
In the "file_managed" table, the new files have "0" for the "uid" & "status" columns. So I get always warnings in the logs...
Comment #21
kumkum29 commented@MegaChriz
For me, the patch #15 don't resolve this problem (maybe I have omitted anything...). Do you think resolve this issue by another way?
Thanks.
Comment #22
megachriz@kumkum29
It looks like that it doesn't fix the whole problem for me either: I still get tons of "Could not delete temporary file" error messages in the log on a site where I applied the patch from #15, but these may be of files that aren't re-imported again.
Comment #23
nwom commentedSetting to "Needs Work" as explained in #22.
Comment #24
paul_constantine commentedHi all,
don't know if this is relevant. But I did notice a value in the exported feeds-importer that I did not set so.
In the UI settings of the Node Processor I set the expiry to "Never". But when I export the feeds-importer I see the expire_period value set to "3600". Does 3600 mean "Never" or does it stand for "1 hour" (60 Seconds x 60)?
Could this be the reason that the files are not set to "permanent"?
Regards,
Paul
Comment #25
bluegeek9 commentedDrupal 7 reached end of life and the D7 version of Feeds is no longer being developed. To keep the issue queue focused on supported versions, we’re closing older D7 issues.
If you still have questions about using Feeds on Drupal 7, feel free to ask. While we won’t fix D7 bugs anymore, we’re happy to offer guidance to help you move forward. You can do so by opening (or reopening) a D7 issue, or by reaching out in the #feeds channel on Drupal Slack.
If this issue is still relevant for Drupal 10+, please open a follow-up issue or merge request with proposed changes. Contributions are always welcome!