As far as I know this only occurs in conjunction with cck and pathauto, but since those are two of the most commonly used contrib modules, it's not a minor issue. So here's the problem:

1) pathauto_nodeapi calls module_invoke_all('pathauto_node', 'values', $node) on a node insert/update
2) which calls content_pathauto_node in content_pathauto.inc
3) which calls node_invoke_nodeapi($node, 'view', false, false);
4) which calls image_view
5) which eventually calls image_display
6) which, if the derivative images need regenerating, calls node_save
7) which calls pathauto_nodeapi...
8) loops infinitely

Now, this is a problem only because it's regenerating images, but nevertheless, it's probably not a good idea to save the new images with a node_save, in order to prevent this infinite loop.

Comments

drewish’s picture

where does cck come into that?

mcarbone’s picture

Step 2: content_pathauto.inc

dsp1’s picture

i had a similar issue. Testing on a local machine I installed 1.4. I updated. Then click on home where some images were. The browser seemed to stall. I happened to have the files/images folder open and it was deleting and adding the same image file over and over. canceled browser to stop.

drewish’s picture

which version of pathauto is that?

dsp1’s picture

I am using 5.x-1.2

drewish’s picture

can you verify the bug with the 5.x-2.x branch?

mcarbone’s picture

Pathauto isn't the problem here -- it just calls module_invoke_all('pathauto_node', 'values', $node) on node insert/updates -- nothing weird there, and it happens in all recent versions (5.x-1.2, 5.x-2.x, HEAD). The problem is with image, which is calling node_save in a place that can potentially also be called by node_save.

What I can't do is verify that drewish's problem is that same as I'm describing here. drewish, can you comment out the node_save in image_display and try it again? If it's still not working, you have a different problem, and should open a new issue.

mcarbone’s picture

Sorry, I means dsp1, not drewish.

drewish’s picture

Status: Active » Closed (duplicate)

i think this is a duplicate of: http://drupal.org/node/129338

mcarbone’s picture

Status: Closed (duplicate) » Active

No, they are entirely different issues. Token has nothing to do with this infinite loop -- this issue is very specific to the node_save in the image_display function.

drewish’s picture

Version: 5.x-1.4 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new3.57 KB

this patch (for HEAD) moves the check for missing images from image_display() to image_load(). and calls image_update() rather than node_save(). i'd love to have some testers running HEAD.

Hetta’s picture

I'd love to oblige, but where can HEAD be downloaded?

drewish’s picture

http://drupal.org/node/94674 but be aware that it has a different table schema so you'll want to run it on a test server.

drewish’s picture

StatusFileSize
new3 KB

here's a version of the patch for the 5.x-1.x branch.

drewish’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
StatusFileSize
new10.46 KB

alright, ignore those last two patches. this one is for the 5.x-1.x branch.

during the node load the module first determines what derivative images should exists and then checks that they do. if there's a problem it regenerates the derivative images and then uses image_update() (rather than node_save() because people didn't like have the last updated date changed) to save the changes.

the good news is that if you're already experiencing screwed up images it should fix them. the bad news is that it rewrites a bunch of stuff so i'm going to need some testers to try this out. please give it a spin and let me know if you run into any errors.

Hetta’s picture

No problem with image import into galleries with this patch applied (to the latest 5.x-1 dev).

drewish’s picture

Heta does that mean it works correctly for you with everything else?

Nick Brown’s picture

I tried the patch, hoping to resolve the issue I'm seeing;
http://drupal.org/node/171524

Although images are now displayed, they are regenerated every time, which results in message being displayed, and slow down in pages loads.

drewish’s picture

NickBrown (or anyone else who's running into this problem) it'd be very helpful if you could hop on IRC in #drupal and spend a little time helping me debug this. If you need some info on getting on IRC give this a read: http://drupal.org/node/108355

zoo33’s picture

I tested this with the latest 5.x-dev versions of Image and Image assist. It works alright, except I'm seeing the message "Missing derivative images were regenerated for test" on every image view. Happens both within Image assist's Add image window and when viewing image nodes, as well as on story nodes that have inline images in them.

So, Image assist integration is *probably* OK. I'll try to keep up to date with this issue to see if new versions of the patch work.

drewish’s picture

StatusFileSize
new14.74 KB

i was hoping to keep this as simple as possible but since it doesn't seem like that's going to happen i'll aim for correct and well tested.

thanks for the feedback i was able to narrow down the cause of the repeated rebuilding. it turns out that i need to differentiate between saving a new file and rebuilding. i think this patch should do it. i've added some debugging messages so if it tries to rebuild the images it'll explain why.

drewish’s picture

StatusFileSize
new37.8 KB

i never do this but i really want the testing/feedback so i'm going to post a patched version of the module. please give it the full run through:
- upload new images
- edit images
- replace existing images
- rebuild thumbnails
- attach images
- import images
- img_assist them..
in short, do your best to break this.

zoo33’s picture

Seems to work. I didn't try everything on your list, but I added images, tried replacing image files, changed size settings etc, while continuously testing them with Image assist.

Only had a slight problem with Image assist when I replaced an image file in an existing image node. The old image paths are still stored in the filter cache of the parent node (such as a story node). That's an img_assist issue though (and it's not a new one). I'm thinking of adding a check for this in img_assist_nodeapi().

Or maybe it's a broader issue... if other modules such as image_attach have similar problems then maybe image.module should empty the filter cache whenever images are replaced? This is unrelated to this issue, but what's your opinion?

Standart’s picture

Did some testing (upload new images, edit images, replace existing images, rebuild thumbnails) and everything seems to work.

Nick Brown’s picture

I'm still having the same problem using the module in comment #22. There are more verbose messages about regenerating images, and no images are displayed;

http://www.nickbroon.com/

Observatory Ridge's thumbnail derivative image was missing. The derivatives will be rebuilt to regenerate it.
Observatory Ridge's preview derivative image was missing. The derivatives will be rebuilt to regenerate it.
The derivative images for Observatory Ridge have been regenerated.

drewish’s picture

NickBrown, looking at your site i think you've got some other issues going on. what image toolkit are you using? can you try out the imagemagick toolkit?

Nick Brown’s picture

I am using the ImageMagick toolkit;

Image toolkit

    Beach's thumbnail derivative image was missing. The derivatives will be rebuilt to regenerate it.
    Beach's preview derivative image was missing. The derivatives will be rebuilt to regenerate it.
    The derivative images for Beach have been regenerated.

Select an image processing toolkit:
*ImageMagick Toolkit.
Built-in GD2 toolkit
Path to the "convert" binary: * /usr/bin/convert
Version:

Version: ImageMagick 6.3.4 08/03/07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC

The path to convert is correct.
The gentoo package I have installed is;

[ebuild   R   ] media-gfx/imagemagick-6.3.4-r1  USE="jpeg zlib -X -bzip2 -doc -fpx -graphviz -gs -hdri -jbig -jpeg2k -lcms -mpeg -nocxx -openexr -perl -png -q32 -q8 -tiff -truetype -wmf -xml" 0 kB
drewish’s picture

NickBrown, try using GD then. other sites keep getting the regenerating message but the images are created and visible. on your site they're continually generated but not visible. are you sure the files path is correct? does the upload.module let you resize uploaded images correctly?

Nick Brown’s picture

The path to cnvert is correct;

which convert
/usr/bin/convert

Using the built in GD toolkit results in the same symptoms (and the image toolkit reports GD toolkit as properly detected and installed)

As I mentioned here when I used the patch in comment #15 images were displayed, but regenerated every time. With the module from comment #22 no images are displayed and the regenerated message displayed everytime.

dsw9742’s picture

drewish-- looks good to me. no problems so far.

drewish’s picture

Status: Needs review » Patch (to be ported)

okay, committed to DRUPAL-5, working on a patch for HEAD.

XGI-Wrath’s picture

Status: Patch (to be ported) » Needs review

Hi...

Sorry to break into your thread like this. But I'm seeing similar symptoms:
- After submitting an image, no version of the image is visible.
- Every attempt to view any version (thumb, preview, original) results in an "access denied" error in the log.
- Occasionally I'm seeing the "regeneration" message in the log.

I wanted to try the patch(s) that have been posted but (please excuse the former Nuke admin's ignorance) I don't know how to apply them. Does anybody have a few seconds to explain how to use the patches after they've been posted? I've noticed at least two different formats, so I'm a little nervous about taking shots in the dark.

Thanks in advance.

-=w=-
http://dfbrigade.org

System Info:
Drupal                                  5.2
Configuration file	            Protected
Cron maintenance tasks	    Last run 2 hours 51 min ago
Database schema	              Up to date
File system                           Writable (private download method)
GD library                             bundled (2.0.28 compatible)
MySQL database                  4.1.22
PHP	                                 4.4.7
Unicode library                     PHP Mbstring Extension
Web server                           Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b
drewish’s picture

Status: Needs review » Patch (to be ported)

the attachment on http://drupal.org/node/160671#comment-297969 is a patched copy of the module (which has been committed and will be in the next -dev release). if you're not comfortable applying patches use that.

drewish’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new17.67 KB

okay here's the patch for HEAD.

HorsePunchKid’s picture

Hi, drewish. I'm using image-5.x-1.x-dev from 2007-09-03 along with the patch from #15 (#comment-297547) above, and it's misbehaving. I'm not sure if this is a combination you expect people to be testing, though. The symptom is that every image on the page you view gets rebuilt every time.

This had the nasty side effect for me of subscribing every (logged in) visitor to every image they saw and then proceeding to send them a notification about it being updated. =O

I'm happy to test further!

drewish’s picture

HorsePunchKid, that patch was for HEAD, not -dev (which is the DRUPAL-5 branch). either wait until the new -dev release is up or just grab the patched version of the module on comment #22.

drewish’s picture

Wrath-BRIG-, see http://drupal.org/patch for information on applying patches.

drewish’s picture

Status: Needs review » Fixed

after some more testing i've committed #34 to HEAD. i'm going to mark this as fixed. if people can try out the updated releases when they post i'd appreciate it.

HorsePunchKid’s picture

I'm still seeing the same behavior, though now I get a convenient link to the regenerated image with every displayed message. This is for image-5.x-1.x-dev timestamped 2007-09-05 00:03. Perhaps I can temporarily just disable rebuilding derivatives, since I'm not uploading new images frequently...

HorsePunchKid’s picture

I have upgraded to image-5.x-1.x-dev posted 12-Sep-2007 12:06, and things seem to be working smoothly.

Anonymous’s picture

Status: Fixed » Closed (fixed)