Problem/Motivation

Whilst this behaviour was exposed on a recent upgrade from 7.x-1.1 to 7.x-1.2, I believe it would have affected earlier versions.

I have a site where filefield_paths_temp_location was set to public://protected/tmp . The site has a custom setup (combination of apache .htaccess rules and custom permissions module) which ensures that public://protected/tmp is not accessible. Upon upgrading to 7.x-1.2, this was rewritten to temporary://protected/tmp . When I then try to upload a file to a field using filefield_paths, the node/add form reports "File upload error. Could not move uploaded file.", and the Drupal log notes

Warning: move_uploaded_file(): Unable to move '/tmp/phpvra1WP' to 'temporary://protected/tmp/file.pdf' in drupal_move_uploaded_file() (line 1711 of /var/www/drupal/alt36/includes/file.inc).

The system uses systemd tmpfiles, so the target file destination is /tmp/$SYSTEMD_TMP_PATH/tmp/protected/tmp/ but there has been no call to e.g. file_prepare_directory() to ensure that that directory exists.

Note that if I go to admin/config/media/file-system/filefield-paths , set the temporary file location and save then the form validation hook calls file_prepare_directory() and creates the appropriate directory structure and I can upload files OK. However, upon rebooting the server, /tmp is of course emptied and I have the same problem.

My workaround has been to manually reset the temporary file location to the original public://protected/tmp (via the admin form to ensure file_prepare_directory() is called, rather than using variable_set as in filefield_paths_update_7108() )

Comments

alt36 created an issue.

alt36’s picture

Also, the upgrade message/comment from hook_update_7108 "Change the temporary path if the site supports private files." is misleading: my site does not have private files enabled, but filefield_paths_temp_location was changed anyway. filefield_paths_recommended_temporary_scheme() loops through $recommended = array('temporary', 'private') so I think 'private' will only be returned if 'temporary' is not writable.

rusylnarito’s picture

files are going to temporary even the public , also private is already configured with writable but still going to temporary