Refresh metadata on album refreshes all images in gallery

When I click on the refresh metadata icon on album from zenphoto/zp-core/admin-edit.php it appears to try and refresh the metadata from all of the images in the album. I can see this because the id value in the URL line is steadily rising from 3112 (the smallest ID in zp_images, up to 4820 at the moment). Having a quick look at the code it looks like what should happen is that the mtime value for the images in the album are set to zero and then any image where the mtime doesn't equal that of the file is refreshed. Running in mySQL:
`SELECT COUNT(*) FROM zp_images WHERE mtime=0;`
gives 52. There are 53 images/videos in the album.

Any ideas what is going wrong? I did have a plugin that filtered on image_refresh but I have removed that for the time being.

I am running zenphoto version 1.2.9 [5088]

Many thanks

Comments

  • First let me make sure we are using the same terms. In Zenphoto we have a gallery that contaions albums. So if you click on the album refresh it should refresh all the images in that album.

    To do so, first it sets mdata to zero for all the images within the album. Then it runs the standard garbage collect function. That function will examine all the images and for those whose mdata does not match the file time it will perform the refresh. Typically this will be just those images within the album.
  • Hi sbillard. Sorry it has taken me a while to reply. Yes that's right. What I think is happening is that when I click on album refresh, it sets the mtime of images in that album to zero but then still goes on to refresh all the images (not just the images in that album).
  • That is how it will work. If that is really an issue we can see if it can be changed. I am not sure.
  • Hmm, if I understand correctly, you're saying that refreshing an "album" will, by design, refresh ALL albums? I would have to classify that as an undesireable bug. If this is the case, then what's the point of a separate refresh button beside each album? That clearly suggests that only the intended album would be refreshed. I can imagine there are cases where specific properties are set for images in one album that would be lost due to a metadata refresh, so users could lose a lot of data when they think they're refreshing a single album and the whole gallery gets refreshed.
  • Well, you are not interpreting exactly correctly. It will refresh only images whose mtime does not match the filemtime of the image. So what will really happen is that it will refresh any out of date images and all images of the album chosen (because those images have their mtime set to zero.)

    No data will be lost (which would not have otherwise been lost) as any image "loaded" which has an mtime mismatch will have its data refreshed.
  • Ahh, I think I see. So refreshing the album will remove the mtime from the database for all images in that album, but the 2nd phase will look for ANY images that have been updated more recently than the database, which will include all images in the current album, and *may* include other images also, but only if those images have indeed been changed since their last update.

    I think I understand now. Is there a particular design reason for this approach, rather than specifically processing only the selected album? I will look through the code to see about making this affect only the selected album, but if there's a known particular reason this approach wasn't taken, it might be good for me to be aware of that in advance...
  • No, it was just the way it was done. If you look at the gallery->garbageCollect() function processing of images you will see that it would be difficult to make it process just the images from one album.

    On the other hand, it can be changed fairly easily to process just the images with `mtime` set to zero, so we will make that change. In effect this does what you want.
  • OK I think I am starting to understand what is suppose to happen. The problem is that for me even after I have left it to refresh the metadata for all the images in the gallery, the next time I try and refresh an album it wants to refresh all the images in the gallery again (even though I have made no changes).

    So that seems to suggest that for some reason the mtime is not matching the filemtime even after a full gallery metadata refresh. But looking at the mtime in the database of an example file and an ls -l they are the same. Hmmmm.
  • So, what leads you to think that all the images are being refreshed? Yes, the image records get examined. That is all you can observe from the URL refresh. That does not mean that anything gets changed. That happens only if the mtimes differ. And once the refresh happens, the mtimes are set identical.
  • You're right, it could be examining every image, and I do have a large gallery. I thought that previously it was quicker, but it might be that I didn't do the album refresh very often. I think the change you have made should optimise it. Thanks
  • One small thing. Shouldn't line 468 be:

    `$restartwhere = ' WHERE id>'.$restart.' AND mtime=0';`

    Many thanks
  • True. Sorry about that. Must have been a senile moment.
Sign In or Register to comment.