I noticed that when you edit/create a component type 'file', when I enter a destination directory, it initially creates one, but then creates another one in a different spot when you start actually submitting the form and uploading files. Damage is minor, as the files are still uploaded, but an unnecessary directory is potentially being created.

Steps to Replicate:

i) Edit/create component (type: File) - Eg. folder "webform/dropbox/student-groups/"
ii) Note that directory is created: sites>default>files>dropbox>student-groups>webform
iii) Submit form
iv) Note that file is actually placed in site>default>files>webform>dropbox>student-groups

Not clear if a bug or a feature I don't fully understand, however thought I should mention it.

Simon

Comments

slismann’s picture

Issue summary: View changes

added one folder item i missed

guedressel’s picture

Issue summary: View changes

I just discovered the source of this problem.
But I'm working on version 3.20.
Guess this issue affects more versions...

guedressel’s picture

Title: Destination file folder initially created is different to one used by form to store files » Destination folder of file components get initially created with wrong path
Version: 7.x-4.0-alpha10 » 7.x-4.x-dev
Component: Miscellaneous » Code
Status: Active » Needs review
StatusFileSize
new650 bytes
new650 bytes

Here are (very trivial) patches to fix this issue.
Patch for 3.x also works for current release 3.20

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Doh! What an obvious problem. Thanks @guedressel! This should be committed on the next pass through the issue queue.

guedressel’s picture

Aonther thought:
Remove the whole line of code - instead of patching it. It's not necessary to create the directory when a file component gets created.
The directory will be created on the first upload anyways.

This would not lead to empty and never used directories...

quicksketch’s picture

It's not necessary to create the directory when a file component gets created.

If there's an error creating the directory, it'd be better to give that to the admin/editor user setting up the Webform than the end-user filling out the form. I think that's the reason for adding/checking it on component save.

guedressel’s picture

If there's an error creating directories in the Drupal public/private files destination Drupal itself will bring up loads of errors before. Don't you think?

quicksketch’s picture

If there's an error creating directories in the Drupal public/private files destination Drupal itself will bring up loads of errors before. Don't you think?

It depends. Never underestimate an administrator's ability to completely screw up their file permissions. It's entirely possible that different directories will have different permissions, so /files/js might be writable but /files/webform may not. I'd still prefer to keep the check where it is.

The patches are still good, so I've committed them. Thanks for your finding/fixing!

  • Commit 895554a on 7.x-3.x by quicksketch:
    Issue #2096525 by guedressel | slismann: Destination folder of file...

  • Commit ed7a4b7 on 7.x-4.x by quicksketch:
    Issue #2096525 by guedressel | slismann: Destination folder of file...
quicksketch’s picture

Status: Reviewed & tested by the community » Fixed
fenstrat’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Fixed » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed ed7a4b7 to 8.x-4.x. Thanks!

  • Commit a669989 on 8.x-4.x by fenstrat:
    Issue #2096525 by guedressel | slismann: Destination folder of file...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.