Upgrade to image 5x 1.1 screws up file paths for old images.
derbz2 - May 8, 2007 - 07:29
| Project: | Image |
| Version: | 5.x-1.x-dev |
| Component: | image.module |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
To fix i commented line 143:
//$dir = './' . variable_get('file_directory_path', 'files') . '/';
I am not providing a patch as is one liner.

#1
Ok, this does not fully fix the bug, the line needs to exist but i think it may need to be rewritten.
#2
So, ya. I was right the first time, Image module is now writing 'files/images/' instead of 'images/' to files table prepending file names which is odd. Removing the line does fix the problem but all previous images' file paths need to be changed in files table.
#3
I am not sure why image is doing this.
The code in image has the same as watermark:
variable_get('file_directory_path', 'files')I am transferring this to image module, to get comments on it, and making it a support request.
#4
it's been putting them inside the files directory for all the 5 versions i've worked with...
#5
The question is:
- What got stored in the files tables in 4.7 (files/images/, or just images/)?
- Did that change for 5.x?
- Why did it change? Is it a bug or a feature.
#6
*subscribe*
Happening here too. I 'upgraded' from Image 5.x-1.0 to 5.x-1.1.
My 'Default image path:' is 'images/node'
My 'File System Path' is 'sites/default/files'
I reverted to the image 5.x-1.0 version and things are back to normal.
#7
I get the same problem:
* Image file ./files/files/images/candersoni(m).jpg not found.* Error adding watermark.
* Image file ./files/files/images/candersoni(m).preview.jpg not found.
* Error adding watermark.
I'm working on a clean install of Drupal 5.1 and I've tried all sorts of things to make sure my path is right.
I'll try out the code change when I get home this evening.
#8
marked http://drupal.org/node/146312 as a duplicate of this.
#9
Someone tried to solve this problem?
I guess this is not a big bug, just remove "files/" from paths before write them to db should be ok...
#10
Keep using image module 1 dev and it still works...
#11
there's some code over on http://drupal.org/node/152093 that might help resolve this.
#12
So yea this is the code drwish is referring too, I don't know how it happened, but the paths being pulled from the files directory are no longer correct on upgrade.
$filepaths = db_query('SELECT fid, filepath FROM files');
while ($paths = db_fetch_array($filepaths)) {
$m++;
$path[$m]['path'] = 'sites/whateveryoursiteis/files/'.$paths['filepath'];
$path[$m]['fid'] = $paths['fid'];
}
foreach($path as $i) {
db_query('UPDATE files SET filepath = "%s" where fid = %d', $i['path'], $i['fid']); }
Here is what I used to fix it - just pasted it into devel.module and ran it to pull all the records and alter them and re-insert them
THIS IS NOT A FIX!!!! Just a start to one - also be ultra careful - if you have more than images stored in files this code as-is WILL break their paths.
Good luck.
#13
i've got a little time now to try to write an update to fix this for people upgrading from 4.7. if you had this issue please contact me via my user contact form. i want to get a copy some of the data in your fiiles table and path and directory listing for the images folder.
#14
okay, here's a patch that should clear it up. i'd love to have some testers. please back up your database before trying this out. i've run it on my sites but i don't have a multisite setup.
#15
little bit better patch. deletes unmatched rows in files_revisions.
#16
#17
this now removes {file} rows with duplicate nid/filepaths.
#18
I've committed this to HEAD and DRUPAL-5.
#19
had a bug in the query. didn't {} table names
#20
i committed that last patch.
#21