Mailsave_to_imagefield D6 port issue
PGiro - May 31, 2009 - 21:41
| Project: | Mailsave |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
I have a node type that holds an imagefield. I have setup its path to be [user-id]/[site-date-YYYY]/[site-date-MM]/[site-date-DD].
When I use mailsave_to_imagefield, the files are not saved to this directory because it is not created on the fly when it does not exist. I have traced the code to that problem and I'm not sure there is a good solution (there must be... this is drupal).
It's all happening in _mailsave_to_imagefield_attempt_image() whene iterating the attachements
// Let's create the directory path if it hasn't been created already
$directory = file_create_path($widget_image_path);
file_check_directory($directory, FILE_CREATE_DIRECTORY);That first line does not create the directory is it doesn't exist when it really should. That's because PHP's realpath() returns an empty string when a path does not exist (at least in 5.x)

#1
Here is my unsatisfactory fix but I can't think of anything better at the moment
$directory = file_directory_path()."/".$widget_image_path; //was file_create_path($widget_image_path);module_load_include('inc','filefield','field_file'); // added
field_file_check_directory($directory, FILE_CREATE_DIRECTORY); // was file_check_directory($directory, FILE_CREATE_DIRECTORY)
#2
Thanks, I incorporated this patch in #315381: D6 port of Mailsave to CCK Imagefield