From 512251865275b441f6fde0706ef9277c72a9217f Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 16 Apr 2010 19:30:07 -0500 Subject: [PATCH] remove useless DESTROYs --- lib/Spectre/Cron.pm | 1 - lib/Spectre/Workflow.pm | 1 - lib/WebGUI/AdSpace.pm | 13 ----------- lib/WebGUI/AdSpace/Ad.pm | 13 ----------- lib/WebGUI/Asset/Wobject/HttpProxy.pm | 2 +- lib/WebGUI/Asset/Wobject/HttpProxy/Parse.pm | 5 ----- lib/WebGUI/DatabaseLink.pm | 1 - lib/WebGUI/FormValidator.pm | 24 ++++++--------------- lib/WebGUI/Group.pm | 16 -------------- lib/WebGUI/HTMLForm.pm | 14 ------------ lib/WebGUI/Inbox.pm | 13 ----------- lib/WebGUI/Inbox/Message.pm | 13 ----------- lib/WebGUI/LDAPLink.pm | 2 +- lib/WebGUI/Search/Index.pm | 13 ----------- lib/WebGUI/Shop/Address.pm | 1 - lib/WebGUI/Shop/AddressBook.pm | 1 - lib/WebGUI/Shop/Transaction.pm | 1 - lib/WebGUI/Shop/TransactionItem.pm | 1 - lib/WebGUI/Workflow.pm | 15 ------------- lib/WebGUI/Workflow/Activity.pm | 15 ------------- lib/WebGUI/Workflow/Cron.pm | 15 ------------- lib/WebGUI/Workflow/Instance.pm | 2 -- lib/WebGUI/Workflow/Spectre.pm | 13 ----------- 23 files changed, 8 insertions(+), 187 deletions(-) diff --git a/lib/Spectre/Cron.pm b/lib/Spectre/Cron.pm index d13f2b876..c101a9e8f 100644 --- a/lib/Spectre/Cron.pm +++ b/lib/Spectre/Cron.pm @@ -49,7 +49,6 @@ Gracefully shuts down the scheduler. sub _stop { my ($kernel, $self) = @_[KERNEL, OBJECT]; $self->debug("Stopping the scheduler."); - undef $self; } #------------------------------------------------------------------- diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index f79e0144e..69a613b2a 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -50,7 +50,6 @@ Gracefully shuts down the workflow manager. sub _stop { my ($kernel, $self) = @_[KERNEL, OBJECT]; $self->debug("Stopping workflow manager."); - undef $self; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AdSpace.pm b/lib/WebGUI/AdSpace.pm index 259f58b73..4b670b70b 100644 --- a/lib/WebGUI/AdSpace.pm +++ b/lib/WebGUI/AdSpace.pm @@ -106,19 +106,6 @@ sub delete { #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 displayImpression ( dontCount ) Finds out what the next ad is to display, increments it's impression counter, and returns the HTML to display it. diff --git a/lib/WebGUI/AdSpace/Ad.pm b/lib/WebGUI/AdSpace/Ad.pm index ca44a95f2..23d147200 100644 --- a/lib/WebGUI/AdSpace/Ad.pm +++ b/lib/WebGUI/AdSpace/Ad.pm @@ -96,19 +96,6 @@ sub delete { #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 get ( name ) Returns the value of a property. diff --git a/lib/WebGUI/Asset/Wobject/HttpProxy.pm b/lib/WebGUI/Asset/Wobject/HttpProxy.pm index 299b9048d..901bcef2f 100644 --- a/lib/WebGUI/Asset/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Asset/Wobject/HttpProxy.pm @@ -442,7 +442,7 @@ sub view { } my $p = WebGUI::Asset::Wobject::HttpProxy::Parse->new($self->session, $proxiedUrl, $var{content}, $self->getId,$self->rewriteUrls,$self->getUrl,$self->urlPatternFilter); $var{content} = $p->filter; # Rewrite content. (let forms/links return to us). - $p->DESTROY; + undef $p; if ($var{content} =~ / 1 ); -sub DESTROY { - my $self = shift; - $self = undef; -} - =head2 new ( $class, $session) Constructor for parser. diff --git a/lib/WebGUI/DatabaseLink.pm b/lib/WebGUI/DatabaseLink.pm index 8dffa550f..a045191a5 100644 --- a/lib/WebGUI/DatabaseLink.pm +++ b/lib/WebGUI/DatabaseLink.pm @@ -213,7 +213,6 @@ sub disconnect { if (defined $self->{_dbh}) { $self->{_dbh}->disconnect() unless ($self->getId eq "0"); } - undef $self; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/FormValidator.pm b/lib/WebGUI/FormValidator.pm index 6c465c382..bb1cada6b 100644 --- a/lib/WebGUI/FormValidator.pm +++ b/lib/WebGUI/FormValidator.pm @@ -17,6 +17,7 @@ package WebGUI::FormValidator; use strict qw(vars subs); use WebGUI::HTML; use WebGUI::Pluggable; +use Scalar::Util qw(weaken); =head1 NAME @@ -79,21 +80,6 @@ sub AUTOLOAD { return $control->getValue(@args); } -#------------------------------------------------------------------- - -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - - - #------------------------------------------------------------------- =head2 get ( ) @@ -120,9 +106,11 @@ A reference to the current session. =cut sub new { - my $class = shift; - my $session = shift; - bless {_session=>$session}, $class; + my $class = shift; + my $session = shift; + my $self = bless {_session=>$session}, $class; + weaken $self->{_session}; + return $self; } diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index 97ceb3c7f..21bba12e5 100644 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -270,7 +270,6 @@ sub delete { $self->session->db->write("delete from groups where groupId=?", [$self->getId]); $self->session->db->write("delete from groupings where groupId=?", [$self->getId]); $self->session->db->write("delete from groupGroupings where inGroup=? or groupId=?", [$self->getId, $self->getId]); - undef $self; } #------------------------------------------------------------------- @@ -363,21 +362,6 @@ sub description { return $self->get("description"); } - -#------------------------------------------------------------------- - -=head2 DESTROY - -Desconstructor - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - - #------------------------------------------------------------------- =head2 expireNotify ( [ value ] ) diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index a02295a63..b304bd2ce 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -91,20 +91,6 @@ sub AUTOLOAD { $self->{_data} .= $control->toHtmlWithWrapper; } -#------------------------------------------------------------------- - -=head2 DESTROY ( ) - -Disposes of the form object. - -=cut - -sub DESTROY { - my $self = shift; - $self = undef; -} - - #------------------------------------------------------------------- =head2 dynamicForm ( $formDefinition, $listName, $who ) diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index 201ff5330..ad02afa12 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -119,19 +119,6 @@ sub canRead { #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 getMessage ( messageId [, userId] ) Returns a WebGUI::Inbox::Message object. diff --git a/lib/WebGUI/Inbox/Message.pm b/lib/WebGUI/Inbox/Message.pm index 642aed264..09fc40c4e 100644 --- a/lib/WebGUI/Inbox/Message.pm +++ b/lib/WebGUI/Inbox/Message.pm @@ -260,19 +260,6 @@ sub delete { #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 get ( property ) Returns the value of a property. diff --git a/lib/WebGUI/LDAPLink.pm b/lib/WebGUI/LDAPLink.pm index 3b413dbb5..5c9f8daec 100644 --- a/lib/WebGUI/LDAPLink.pm +++ b/lib/WebGUI/LDAPLink.pm @@ -121,10 +121,10 @@ sub connectToLDAP { } #------------------------------------------------------------------- + sub DESTROY { my $self = shift; $self->unbind; - undef $self; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Search/Index.pm b/lib/WebGUI/Search/Index.pm index 1ac78afbe..1538cd09d 100644 --- a/lib/WebGUI/Search/Index.pm +++ b/lib/WebGUI/Search/Index.pm @@ -151,19 +151,6 @@ sub delete { #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 _filterKeywords ( $keywords ) Perform filtering and cleaning up of the keywords before submitting them. Ideographic characters are padded diff --git a/lib/WebGUI/Shop/Address.pm b/lib/WebGUI/Shop/Address.pm index 8448a6f85..49631c78c 100644 --- a/lib/WebGUI/Shop/Address.pm +++ b/lib/WebGUI/Shop/Address.pm @@ -91,7 +91,6 @@ Removes this address from the book. sub delete { my $self = shift; $self->addressBook->session->db->deleteRow("address","addressId",$self->getId); - undef $self; return undef; } diff --git a/lib/WebGUI/Shop/AddressBook.pm b/lib/WebGUI/Shop/AddressBook.pm index 06d95afd5..dd23e7c41 100644 --- a/lib/WebGUI/Shop/AddressBook.pm +++ b/lib/WebGUI/Shop/AddressBook.pm @@ -91,7 +91,6 @@ sub delete { $address->delete; } $self->session->db->write("delete from addressBook where addressBookId=?",[$self->getId]); - undef $self; return undef; } diff --git a/lib/WebGUI/Shop/Transaction.pm b/lib/WebGUI/Shop/Transaction.pm index 7619dbc51..31190b8c0 100644 --- a/lib/WebGUI/Shop/Transaction.pm +++ b/lib/WebGUI/Shop/Transaction.pm @@ -182,7 +182,6 @@ sub delete { $item->delete; } $self->session->db->write("delete from transaction where transactionId=?",[$self->getId]); - undef $self; return undef; } diff --git a/lib/WebGUI/Shop/TransactionItem.pm b/lib/WebGUI/Shop/TransactionItem.pm index 60c2a37c8..4e52b29a0 100644 --- a/lib/WebGUI/Shop/TransactionItem.pm +++ b/lib/WebGUI/Shop/TransactionItem.pm @@ -74,7 +74,6 @@ Removes this item from the transaction. sub delete { my $self = shift; $self->transaction->session->db->deleteRow("transactionItem","itemId",$self->getId); - undef $self; return undef; } diff --git a/lib/WebGUI/Workflow.pm b/lib/WebGUI/Workflow.pm index 4232fdf63..5b2d505d5 100644 --- a/lib/WebGUI/Workflow.pm +++ b/lib/WebGUI/Workflow.pm @@ -163,21 +163,6 @@ sub demoteActivity { } } - -#------------------------------------------------------------------- - -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - - #------------------------------------------------------------------- =head2 get ( name ) diff --git a/lib/WebGUI/Workflow/Activity.pm b/lib/WebGUI/Workflow/Activity.pm index 23bfb6ee6..25f8833d9 100644 --- a/lib/WebGUI/Workflow/Activity.pm +++ b/lib/WebGUI/Workflow/Activity.pm @@ -169,23 +169,8 @@ sub delete { my $sth = $self->session->db->prepare("delete from WorkflowActivityData where activityId=?"); $sth->execute([$self->getId]); $self->session->db->deleteRow("WorkflowActivity","activityId",$self->getId); - undef $self; } -#------------------------------------------------------------------- - -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - - #------------------------------------------------------------------- =head2 execute ( object, instance ) diff --git a/lib/WebGUI/Workflow/Cron.pm b/lib/WebGUI/Workflow/Cron.pm index 1e0532bd7..a152965b4 100644 --- a/lib/WebGUI/Workflow/Cron.pm +++ b/lib/WebGUI/Workflow/Cron.pm @@ -87,23 +87,8 @@ sub delete { if (! $skipNotify) { WebGUI::Workflow::Spectre->new($self->session)->notify("cron/deleteJob", $self->session->config->getFilename."-".$self->getId); } - undef $self; } -#------------------------------------------------------------------- - -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - - #------------------------------------------------------------------- =head2 get ( name ) diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index a0df11343..7136b9303 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -106,7 +106,6 @@ sub delete { $self->session->db->write("delete from WorkflowInstanceScratch where instanceId=?",[$self->getId]); $self->session->db->deleteRow("WorkflowInstance","instanceId",$self->getId); WebGUI::Workflow::Spectre->new($self->session)->notify("workflow/deleteInstance",$self->getId) unless ($skipNotify); - undef $self; } #------------------------------------------------------------------- @@ -143,7 +142,6 @@ sub DESTROY { $self->start; } delete $self->{_workflow}; - undef $self; } diff --git a/lib/WebGUI/Workflow/Spectre.pm b/lib/WebGUI/Workflow/Spectre.pm index 6ed59ac34..cc348affc 100644 --- a/lib/WebGUI/Workflow/Spectre.pm +++ b/lib/WebGUI/Workflow/Spectre.pm @@ -39,19 +39,6 @@ These methods are available from this class: #------------------------------------------------------------------- -=head2 DESTROY ( ) - -Deconstructor. - -=cut - -sub DESTROY { - my $self = shift; - undef $self; -} - -#------------------------------------------------------------------- - =head2 notify ( module, params ) Sends a message to Spectre.