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

derbz2 - May 8, 2007 - 10:16

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

#2

derbz2 - May 8, 2007 - 11:01

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

kbahey - May 9, 2007 - 02:55
Project:Image watermark» Image
Version:5.x-1.x-dev» 5.x-1.x-dev
Component:Code» image.module
Category:bug report» support request
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.

#4

drewish - May 9, 2007 - 04:01

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

#5

kbahey - May 9, 2007 - 04:02

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

Michael Curry - May 13, 2007 - 18:40

*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

tknospdr - May 16, 2007 - 20:26

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

drewish - May 23, 2007 - 19:16

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

#9

mianwo - May 25, 2007 - 08:35

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

OSLinux - June 5, 2007 - 06:24

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

#11

drewish - June 16, 2007 - 02:24

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

#12

Tresler - June 24, 2007 - 18:14

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

drewish - June 30, 2007 - 22:11

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

drewish - July 2, 2007 - 23:51
Status:active» needs review

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.

AttachmentSizeStatusTest resultOperations
image_142178.patch1.66 KBIgnoredNoneNone

#15

drewish - July 3, 2007 - 15:16

little bit better patch. deletes unmatched rows in files_revisions.

AttachmentSizeStatusTest resultOperations
image_142178_0.patch2.07 KBIgnoredNoneNone

#16

drewish - July 3, 2007 - 15:23
Title:Upgrade to image 5x 1.1 breaks watermark png path» Upgrade to image 5x 1.1 screws up file paths for old images.

#17

drewish - July 3, 2007 - 18:11

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

AttachmentSizeStatusTest resultOperations
image_142178_1.patch2.44 KBIgnoredNoneNone

#18

drewish - July 6, 2007 - 15:27
Status:needs review» fixed

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

#19

drewish - July 7, 2007 - 19:17
Status:fixed» needs review

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

AttachmentSizeStatusTest resultOperations
image_142178_3.patch702 bytesIgnoredNoneNone

#20

drewish - July 7, 2007 - 20:30
Status:needs review» fixed

i committed that last patch.

#21

Anonymous - July 21, 2007 - 20:45
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.