From 18e24618e754b69080e98d4d6040e3a063ac8276 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 15 Feb 2006 04:31:29 +0000 Subject: [PATCH] eliminated the purgeBranch method, cuz purge() should always do that anyway. --- lib/WebGUI/AssetBranch.pm | 18 ------------------ lib/WebGUI/AssetTrash.pm | 8 ++++++-- lib/WebGUI/AssetVersioning.pm | 2 +- sbin/Hourly/DeleteExpiredTrash.pm | 2 +- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index 813ed80bd..9fee40665 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -67,24 +67,6 @@ sub duplicateBranch { } -#------------------------------------------------------------------- - -=head2 purgeBranch ( ) - -Returns 1. Purges self and all descendants. - -=cut - -sub purgeBranch { - my $self = shift; - my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1, invertTree=>1, statesToInclude=>['published', 'clipboard', 'clipboard-limbo','trash','trash-limbo']}); - foreach my $descendant (@{$descendants}) { - $descendant->purge; - } - return 1; -} - - #------------------------------------------------------------------- =head2 www_editBranch ( ) diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index 3a3660617..a5337683e 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -90,13 +90,17 @@ sub getAssetsInTrash { =head2 purge ( ) -Deletes an asset from tables and removes anything bound to that asset. +Deletes an asset from tables and removes anything bound to that asset, including descendants. =cut sub purge { my $self = shift; - return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage")); + return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage") || $self->get("isSystem"); + my $kids = $self->getLineage(["children"],{returnObjects=>1, statesToInclude=>['published', 'clipboard', 'clipboard-limbo','trash','trash-limbo']}); + foreach my $kid (@{$kids}) { + $kid->purge; + } $self->session->db->beginTransaction; foreach my $definition (@{$self->definition($self->session)}) { $self->session->db->write("delete from ".$definition->{tableName}." where assetId=".$self->session->db->quote($self->getId)); diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 93bf8a5ee..833e938bd 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -210,7 +210,7 @@ sub purgeRevision { $self->purgeCache; $self->updateHistory("purged revision ".$self->get("revisionDate")); } else { - $self->purgeBranch; + $self->purge; } } diff --git a/sbin/Hourly/DeleteExpiredTrash.pm b/sbin/Hourly/DeleteExpiredTrash.pm index 1f264fcbc..8dad6004e 100644 --- a/sbin/Hourly/DeleteExpiredTrash.pm +++ b/sbin/Hourly/DeleteExpiredTrash.pm @@ -23,7 +23,7 @@ sub process { my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and stateChanged <".$expireDate); while (my ($id, $class) = $sth->array) { my $asset = WebGUI::Asset->new($id,$class); - $asset->purgeBranch; + $asset->purge; } $sth->finish; }