summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-08-06 00:39:36 +0000
committerivan <ivan>2009-08-06 00:39:36 +0000
commit833feb1713594b0146c230f8957d91e14ba0e436 (patch)
tree7f102ac53351c4517b49ce3c80247601151cdbd2
parent94a66b78bcda5605d7ee5eb7c3e692fb2fe5cf2c (diff)
delete phone_device records when svc_phone is deleted, RT#5226
-rw-r--r--FS/FS/svc_phone.pm35
1 files changed, 34 insertions, 1 deletions
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index badbb4eb4..11a5a0ee0 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -3,7 +3,7 @@ package FS::svc_phone;
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 @@ Delete this record from the database.
=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