Wrong path to images rendered in pages - using symbolic link
| Project: | Avatar Selection |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Please forgive what might be a silly issue. We created a Drupal v6.4 site many months ago and added avatar_selection. I haven't been able to spend time with the environment and I've forgotten way too much...
All images display with the following URL:
http://sub.domain.com/sites/sub.domain.com/files//a0001.jpg
I don't know when this started. The actual path to the data on the server is:
/common/sites/sub.domain.com/files/avatar_selection
That avatar_selection directory is actually a symbolic link which goes to a lower level directory which is used to support several websites. The idea is to have a single directory with all avatars that's shared among sites - rather than duplicating hundreds of image files for every site. So note that instead of seeing the name of the symbolic link that we simply get two consecutive slashes.
Is there some kind of issue in Drupal which causes it to not follow symlinks? Something with is_dir(), is_writable() or some operation that verifies the integrity of a path?
Any other ideas about how to fix this other than to put all images under file_directory_path()?
I'll take this up with our webhost as well (DreamHost).
Thanks!

#1
I don't know why that would happen. Where does it happen? Does it happen on saved user avatars? Or just on the avatar_selection admin pages?
#2
It's on both admin and user selection pages. I've deleted the symlink and copied all files into a standard avatar_selection directory, and it all works as expected. I'm not sure where to find this in the code but Drupal definitely doesn't like the symlinks.
#3
If a user selects one of the pictures as his/her avatar, is the image path that is stored with the user profile incorrect? What platform are you on? I won't get to look into this in any more detail until after this week I'm afraid.
Cheers,
Stella
#4
I understand the thought process. Now that I've changed the symlink to a real directly I'm afraid I won't be able to answer that question without a great deal of effort.
Platform is Debian Linux with PHP 5.2.6. So far no one on this shared host is reporting issues with symlinks.
I wish it were easier to find out if Drupal 6.4 itself has an issue with symlinks but I've done searches and come up with nothing conclusive for this release. The issue seems clear - one of the processes that generates the pathname does a validation of the path and for "some reason" chooses to return null when the path cannot be verified.
I hate to bother you with such a thing, Stella. I'm mostly documenting the issue here in case anyone else finds it, and hoping someone (myself included) can figure out where that path generation is occurring so that the issue can be found.
Actually, if my analysis is correct, there are two issues:
1) The check for is_dir() or is_writable() or some similar function is failing on a symlink.
2) When this check fails no error is reported but null is returned - I think when a directory can't be found that we should be able to see some record of it in an error log somewhere.
If you can point me in a specific direction I'll be happy to try to do my own homework and assist with the diagnostic.
Thanks!
#5
I looked into this and the problem is that
file_create_path(), which is the Drupal function used to determine the path to theavatar_selectiondirectory, will return FALSE if the path resides outside thefilesfolder. It can handle symbolic links fine, but the directory the link points to must reside within the files directory.However, there is a workaround. Create the
avatar_selectiondirectory in your site'sfilesdirectory. Then inside the avatar_selection dir, create a symlink to your files. This should work with the latest dev release, which supports sub-dirs, and with the 'public' file system method.Cheers,
Stella
#6
Automatically closed -- issue fixed for 2 weeks with no activity.