Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 2 files changed
  • 1 commit comment
  • 1 contributor
Commits on Jan 31, 2013
@bharat bharat Support additional where tuples in ORM_MPTT::parents. Fixes #1980. 71cf911
@bharat bharat 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.
8d15e5c
Showing with 10 additions and 10 deletions.
  1. +8 −9 modules/gallery/helpers/item.php
  2. +2 −1 modules/gallery/libraries/ORM_MPTT.php
View
17 modules/gallery/helpers/item.php
@@ -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);
}
}
}
View
3 modules/gallery/libraries/ORM_MPTT.php
@@ -152,8 +152,9 @@ function parent() {
*
* @return array ORM
*/
- function parents() {
+ function parents($where=null) {
return $this
+ ->merge_where($where)
->where("left_ptr", "<=", $this->left_ptr)
->where("right_ptr", ">=", $this->right_ptr)
->where("id", "<>", $this->id)

Showing you all comments on commits in this comparison.

@shadlaws
Gallery Role Account member

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

Something went wrong with that request. Please try again.