From 970eeb048acce806df6d54ff287c37e42a9af7e2 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 13 Jan 2006 17:53:53 +0000 Subject: [PATCH] adding deconstructors --- lib/WebGUI/SQL.pm | 15 +++++++++++++++ lib/WebGUI/Session.pm | 22 +++++++++++++++++----- lib/WebGUI/User.pm | 14 ++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 825fcaa50..709f3111a 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -274,6 +274,21 @@ sub deleteRow { } +#------------------------------------------------------------------- + +=head DESTROY ( ) + +Deconstructor. + +=cut + +sub DESTROY { + my $self = shift; + $self->disconnect; + undef $self; +} + + #------------------------------------------------------------------- =head2 disconnect ( ) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 7716a8503..6e07f6a54 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -99,12 +99,10 @@ Cleans up a WebGUI session information from memory and disconnects from any reso sub close { my $self = shift; - $self->asset->DESTROY() if (exists $self->asset && $self->asset ne ""); - foreach my $slavedbh (@{$self->{_slave}}) { - $slavedbh->disconnect(); + foreach my $object (keys %{$self}) { + $self->{$object}->DESTROY; } - $self->{_db}->disconnect if (exists $self->{_db}); - undef %session; + undef $self; } #------------------------------------------------------------------- @@ -179,6 +177,20 @@ sub dbSlave { } +#------------------------------------------------------------------- + +=head DESTROY ( ) + +Deconstructor. + +=cut + +sub DESTROY { + my $self = shift; + $self->close; +} + + #------------------------------------------------------------------- =head2 env ( ) diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 4f21f1ef0..051a9e86b 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -173,6 +173,20 @@ sub deleteFromGroups { $group->deleteUsers([$self->userId],$groups); } +#------------------------------------------------------------------- + +=head DESTROY ( ) + +Deconstructor. + +=cut + +sub DESTROY { + my $self = shift; + undef $self; +} + + #------------------------------------------------------------------- =head2 getGroups ( [ withoutExpired ] )