[freeside-commits] freeside/FS/FS svc_phone.pm,1.19,1.20
Ivan,,,
ivan at wavetail.420.am
Wed Aug 5 17:39:38 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv28049
Modified Files:
svc_phone.pm
Log Message:
delete phone_device records when svc_phone is deleted, RT#5226
Index: svc_phone.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_phone.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- svc_phone.pm 30 Jun 2009 01:42:55 -0000 1.19
+++ svc_phone.pm 6 Aug 2009 00:39:36 -0000 1.20
@@ -3,7 +3,7 @@
use strict;
use vars qw( @ISA @pw_set $conf );
use FS::Conf;
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
use FS::Msgcat qw(gettext);
use FS::svc_Common;
use FS::part_svc;
@@ -152,6 +152,39 @@
=cut
+sub delete {
+ my $self = shift;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ foreach my $phone_device ( $self->phone_device ) {
+ my $error = $phone_device->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ my $error = $self->SUPER::delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
+}
+
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
More information about the freeside-commits
mailing list