From dc5d96dd5bd4f42e38bb04c196defd4cd51f5c64 Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Fri, 13 Oct 2006 14:17:08 +0000 Subject: [PATCH] Fixing lineage length bug --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/AssetLineage.pm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index dd24ded7e..1d3f68d7b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ - fix: Snippet Security Fails - add: asset exporter making appropriate symlinks for extras, uploads, and root URL - change: asset exporter now uses one session per asset to avoid breaking state in between + - fix: Lineage length is not checked (Martin Kamerbeek / Procolix) 7.1.0 - fix: mysql and mysqldump were transposed in upgrade.pl --help diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index f07a45e56..1e1436056 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -65,6 +65,11 @@ sub addChild { $properties->{groupIdView} ||= '7'; $properties->{styleTemplateId} ||= 'PBtmpl0000000000000060'; + # Check if it is possible to add a child to this asset. If not add it as a sibling of this asset. + if (length($self->get("lineage")) >= 252) { + $self->session->errorHandler->warn('Tried to add child to asset "'.$self->getId.'" which is already on the deepest level. Adding it as a sibling instead.'); + return $self->getParent->addChild($properties, $id, $now); + } my $lineage = $self->get("lineage").$self->getNextChildRank; $self->{_hasChildren} = 1; $self->session->db->beginTransaction;