Download & Extend

file_directory_path no longer exists in Drupal 7

Project:Webform
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

In components/file.inc, line 275, is a call to file_directory_path() , which no longer exists in Drupal 7.
It makes Webform unusable to send attached files.

Comments

#1

Status:active» postponed

Yep, D7 Webform has postponed development until D7 stabilizes.

#2

It's in beta now, should be good to go ahead and fix. Thanks

#3

We were in code freeze a year ago, beta doesn't mean anything other than the upgrade path now works.

#4

Version:7.x-3.0-beta8» 7.x-3.x-dev
Status:postponed» needs review

This patch replaces file_directory_path with file_build_uri to get a path to the default files folder.

AttachmentSize
930082-getting-rid-of-file_directory_path.patch 2.54 KB

#5

I filed #942974: WSOD on private file downloads as a separate issue, so I don't think webform_file_download() is worth patching here. The only other use of file_directory_path is for the field_prefix on the file component edit form. I changed that so that we're displaying the actual directory the files will go in - I think sites/mysite.com/files/webform/ will make more sense to people than public://webform/.

AttachmentSize
930082-5-file-directory-path.patch 1.03 KB

#6

There is one other mention of file_directory_path in the comment of _webform_recursive_delete, so this patch includes a changed comment in addition to ksenzee's patch in #5.

This is RTBC for the part in #5, so only review needed for the comment.

AttachmentSize
930082-6-file-directory-path.patch 1.84 KB

#7

Status:needs review» fixed

Thanks ksenzee and Stevel for the patches. I've rerolled it to remove _webform_delete_recursive() entirely, since we can now use file_unmanaged_delete_recursive() provided by core instead. Committed to HEAD.

AttachmentSize
webform_file_directory_path.patch 2.46 KB

#8

Sorry - I removed that mention in the comment precisely because I was going to suggest nixing _webform_delete_recursive, then I forgot to say why I did it. Luckily quicksketch is way ahead of me.

#9

Status:fixed» closed (fixed)

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

#10

You Can use this in drupal 7

$files_dir = file_stream_wrapper_get_instance_by_uri('public://')->getDirectoryPath();

instead of

file_directory_path();

#11

To get full path, please use
file_stream_wrapper_get_instance_by_uri('public://')->realpath();