Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Follow-in to cff1e76 for #1978

Restrict which album cover ids we swap over to the hierarchy of the
current album, otherwise we can wind up in sticky situations with
hierarchical album cover chains.

Eg, you have a hierarchy like this:

root -> A1 -> A2 --> A3 -> P1
                     A4 -> P2

P1 is the album cover for its entire hierarchy.  But then you
swap A2's album cover for A3 making this:

root -> A1 -> A2 +   A3 -> P1
                 \-> A4 -> P2

Since A1, A2 and A3 all had P1 as their album cover item id.  Now
we're swapping it over to P2 but we want to leave P1 as A3's album
cover item id.  So only look at A4's hierarchy and ignore its peers.
  • Loading branch information...
commit 8d15e5cb2eed56bbd894ff5578d081deee8ca255 1 parent 71cf911
Bharat Mediratta bharat authored
Showing with 8 additions and 9 deletions.
  1. +8 −9 modules/gallery/helpers/item.php
17 modules/gallery/helpers/item.php
View
@@ -92,16 +92,15 @@ static function make_album_cover($item) {
// When albums are album covers themselves, we hotlink directly to the target item. This
// means that when we change an album cover, the grandparent may have a deep link to the old
- // album cover. So find any albums that had the old item as their album cover and switch them
- // over to the new item.
+ // album cover. So find any parent albums that had the old item as their album cover and
+ // switch them over to the new item.
if ($old_album_cover_id) {
- foreach (ORM::factory("item")
- ->where("album_cover_item_id", "=", $old_album_cover_id)
- ->find_all() as $other_album) {
- if (access::can("edit", $other_album)) {
- $other_album->album_cover_item_id = $parent->album_cover_item_id;
- $other_album->save();
- graphics::generate($other_album);
+ foreach ($item->parents(array(array("album_cover_item_id", "=", $old_album_cover_id)))
+ as $ancestor) {
+ if (access::can("edit", $ancestor)) {
+ $ancestor->album_cover_item_id = $parent->album_cover_item_id;
+ $ancestor->save();
+ graphics::generate($ancestor);
}
}
}

1 comment on commit 8d15e5c

Shad Laws
Collaborator

Nice catch! I was just noticing these problems, but before I could think to do anything about them they were already fixed :-).

Please sign in to comment.
Something went wrong with that request. Please try again.