Drupal 10, the latest version of the open-source digital experience platform with even more features, is here.In file_unmanaged_save_data() we create a temporary file, then move it into place. However, if the move fails, we end up with stale temp files. These are owned www-data:www-data and have mode 0600 by default, which can cause problems with backup scripts (i.e., Aegir) and such that won't be able to read them.
It's a pretty simple matter to check the return value of file_unmanaged_move(), and delete the temp file if the move failed. This function is identical in D7 and D8, but I'll post patches shortly for both.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | drupal-clean_up_temp_files-2496173-1-d8.patch | 645 bytes | ergonlogic |
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 95,160 pass(es). View | |||
| #1 | drupal-clean_up_temp_files-2496173-1-d7.patch | 627 bytes | ergonlogic |
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch drupal-clean_up_temp_files-2496173-1-d7.patch. Unable to apply patch. See the log in the details link for more information. View | |||











Comments
Comment #1
ergonlogicHere are the patches.
Comment #2
ergonlogicComment #4
cilefen CreditAttribution: cilefen commentedIs there any way data could be lost?
Comment #5
ergonlogicNot really. These files are randomly named, so they couldn't really be recovered. This only happens if there's a failure downstream. It just cleans up the temp files.
Comment #6
ergonlogicI think we might be better off just calling
drupal_unlink()directly, rather thanfile_unmanaged_delete()here.Comment #7
dawehnerI'm curious whether we can test this behaviour here?
Comment #8
dagomar CreditAttribution: dagomar commentedI had the same problem, this patch does fix this for me (drupal 7).
Comment #9
alexpottWe need an answer @dawehner's question in #7 as to whether this is testable..
I think using file_unmanaged_delete() is fine.
Comment #11
helmo CreditAttribution: helmo at Initfour websolutions for Aegir Cooperative commentedCould we test this by calling file_unmanaged_save_data() with a destination that we know does not exist? The problem then is though that we don't know the $temp_name outside this function.
Comment #13
20th CreditAttribution: 20th commentedComment #15
maustyle CreditAttribution: maustyle commentedremoved by author.