From 00de81868bbde4095579cf2d8253e088e80904c8 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 28 Jul 2006 23:40:06 +0000 Subject: [PATCH] Two bugs in rollback. The check for rolling back the pbversion0000000000001 tag wouldn't log any errors because it was after the return 0 statement. If a set of assets that were programmatically generated were rolled back, and the assets had a parent child relationship then there's a race condition that could cause the parent to be purged before child. Since purging the parent _also_ purges the child, the system would try to purge the child twice and this causes a fatal error. Programmatically generating the assets causes their revisionDates to be the same, and that causes the return order of the assets to be uncertain. The solution is to generate the list of assets to be rolled back by revisionDate _AND_ lineage. This guarantees that children are purged first. This bug was exposed in t/Macro/RootTitle.t However, the bug seems to be system dependent since the revisionDate depends on how fast the system can create assets. --- lib/WebGUI/VersionTag.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index 60a54bd7b..27b5f03a6 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -327,10 +327,10 @@ sub rollback { my $self = shift; my $tagId = $self->getId; if ($tagId eq "pbversion0000000000001") { - return 0; $self->session->errorHandler->warn("You cannot rollback a tag that is required for the system to operate."); + return 0; } - my $sth = $self->session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ? order by assetData.revisionDate desc", [ $tagId ]); + my $sth = $self->session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ? order by assetData.revisionDate desc, asset.lineage desc", [ $tagId ]); while (my ($class, $id, $revisionDate) = $sth->array) { my $revision = WebGUI::Asset->new($self->session,$id, $class, $revisionDate); $revision->purgeRevision;