To fix i commented line 143:

//$dir = './' . variable_get('file_directory_path', 'files') . '/';

I am not providing a patch as is one liner.

Comments

derbz2’s picture

Ok, this does not fully fix the bug, the line needs to exist but i think it may need to be rewritten.

derbz2’s picture

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.

kbahey’s picture

Project: Image watermark » Image
Component: Code » image.module
Category: bug » support
Status: Needs review » Active

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.

drewish’s picture

it's been putting them inside the files directory for all the 5 versions i've worked with...

kbahey’s picture

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.

mcurry’s picture

*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.

tknospdr’s picture

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.

drewish’s picture

marked http://drupal.org/node/146312 as a duplicate of this.

mianwo’s picture

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...

OSLinux’s picture

Keep using image module 1 dev and it still works...

drewish’s picture

there's some code over on http://drupal.org/node/152093 that might help resolve this.

Tresler’s picture

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.

drewish’s picture

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.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new1.66 KB

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.

drewish’s picture

StatusFileSize
new2.07 KB

little bit better patch. deletes unmatched rows in files_revisions.

drewish’s picture

Title: Upgrade to image 5x 1.1 breaks watermark png path » Upgrade to image 5x 1.1 screws up file paths for old images.
drewish’s picture

StatusFileSize
new2.44 KB

this now removes {file} rows with duplicate nid/filepaths.

drewish’s picture

Status: Needs review » Fixed

I've committed this to HEAD and DRUPAL-5.

drewish’s picture

Status: Fixed » Needs review
StatusFileSize
new702 bytes

had a bug in the query. didn't {} table names

drewish’s picture

Status: Needs review » Fixed

i committed that last patch.

Anonymous’s picture

Status: Fixed » Closed (fixed)