From e20da7110c624325f2a81a9d720d3493f7263ecc Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 15 Nov 2013 18:00:08 -0800 Subject: [PATCH] fix job queue operation with FKs, RT#13971 --- FS/FS/Schema.pm | 4 +++- FS/FS/queue.pm | 29 +---------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index ebf4f37da..bc9d37aed 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3,7 +3,7 @@ package FS::Schema; use vars qw(@ISA @EXPORT_OK $DEBUG $setup_hack %dbdef_cache); use subs qw(reload_dbdef); use Exporter; -use DBIx::DBSchema 0.43; #0.43 for foreign keys +use DBIx::DBSchema 0.44; #for foreign keys with MATCH / ON DELETE/UPDATE use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::Index; @@ -3954,6 +3954,7 @@ sub tables_hashref { 'foreign_keys' => [ { columns => [ 'jobnum' ], table => 'queue', + on_delete => 'CASCADE', }, ], }, @@ -3974,6 +3975,7 @@ sub tables_hashref { { columns => [ 'depend_jobnum' ], table => 'queue', references => [ 'jobnum' ], + on_delete => 'CASCADE', }, ], }, diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 3f8763da8..8ebadd417 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -193,20 +193,6 @@ deleted as well 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; - - my @del = qsearch( 'queue_arg', { 'jobnum' => $self->jobnum } ); - push @del, qsearch( 'queue_depend', { 'depend_jobnum' => $self->jobnum } ); - my $reportname = ''; if ( $self->status =~/^done/ ) { my $dropstring = rooturl(). '/misc/queued_report\?report='; @@ -216,20 +202,7 @@ sub delete { } my $error = $self->SUPER::delete; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - } - - foreach my $del ( @del ) { - $error = $del->delete; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - } - } - - $dbh->commit or die $dbh->errstr if $oldAutoCommit; + return $error if $error; unlink $reportname if $reportname; -- 2.11.0