When an image node is edited it changes position in the gallery, and in image taxonomy listings. This is not the usual 'most recently edited' item floating to the top. The edited image simply shifts to a different place in the gallery with no apparent logic.

As far as I can tell this happens because image module sorts the images in a gallery by the node creation timestamp, and for some reason the creation timestamp is being incremented a little on editing the node. (Of course the changed timestamp also changes as expected.)

Here's and example.
Lets take this gallery http://sphop.perlucida.com/image/tid/62

And change the title from sphp_2002_061_henk.jpg to Seagulls on this image:
http://sphop.perlucida.com/node/322

Prior to the change we have the following (info extracted from the db):
nid: 322
title: sphp_2002_061_henk.jpg
created: 1117550744
changed: 1117550744

And the image is listed between sphp_2002_062_henk.jpg and sphp_2002_060_henk.jpg as you'd expect.

We change the title and image moves to appear between sphp_2002_067_henk.jpg and sphp_2002_066_henk.jpg as you can see:
http://sphop.perlucida.com/image/tid/62?from=12

The db now gives:
nid: 322
title: Seagulls
created: 1117550756
changed: 1117558316

So, why does the created timestamp change at all, and can I stop that happening?

I should say that the images in the gallery were initially imported using import_image.module - but I don't see what this could have to do with that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dtan’s picture

FileSize
591 bytes

You'll notice that there is an authored on text box. . .it doesn't provide seconds, so when the timestamp is created, it picks up the current minutes seconds. Thus if you edit a node (any type) and view its created field in the db, and continuously repeat over 60 seconds, you will see the created loop back down.

Here is the patch. . .which is actually applied to the node.module.

ezheidtmann’s picture

dtan, your patch contains html.

dtan’s picture

FileSize
591 bytes

another one :)

Jose Reyero’s picture

Hey dtan, I'd say very good catch :-) , tested the patch and seems to be ok.

Anyway, I think this bugfix needs to be posted to Drupal core.

mfb’s picture

+1

adrinux’s picture

Title: Edited image nodes change position in the gallery - created timestamp is increased » node created timestamp changes on node edit
Project: Image » Drupal core
Version: 4.6.x-1.x-dev » 4.6.0
Component: image.module » node.module

No time to test this until next week myself, but It's already got two +'s so I'm moving it to core and re-titleing.
Thanks to dtan for hunting this one down :)

adrinux’s picture

Had time to test dtan's patch properly and can now say definitively that it does fix this problem.

That is, without this patch the node created timestamp changes on a node edit. With this patch applied only the node changed timestamp changes, as you'd expect.

So +1 on this getting applied ASAP.

adrinux’s picture

I made a version of this patch for CVS HEAD: http://drupal.org/node/26960

killes@www.drop.org’s picture

Version: 4.6.0 »
Status: Needs review » Reviewed & tested by the community
FileSize
602 bytes

Ok, it is a bit difficult to see why this fixes the problem, but yes it does. The incorrect data format causes node->created to change by up to 59 seconds which can cause time ordered nodes eg from uploads to change position.

I've re-roles the patch for cvs from http://drupal.org/node/26960 and attach it here.

killes@www.drop.org’s picture

The previous review was brought to you by Patch Bingo!

http://drupal.org/patchbingo

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD and DRUPAL-4-6.

Anonymous’s picture

Uwe Hermann’s picture

Version: » 4.6.0
Status: Fixed » Closed (fixed)