summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2009-08-01 19:16:47 +0000
committerjeff <jeff>2009-08-01 19:16:47 +0000
commit9f64bfef652922b7b546a12290805710acbeed08 (patch)
tree00bfda66e9a8bf6ed30420775e712b72f9135c49 /FS
parent7f43bf155bc79e3c9bd5d88e53117595963c301e (diff)
support broader array of queue args #5855, fallout from #5495
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/queue.pm17
-rw-r--r--FS/FS/queue_arg.pm3
3 files changed, 15 insertions, 6 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 15adba3..80aed82 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1622,6 +1622,7 @@ sub tables_hashref {
'columns' => [
'argnum', 'serial', '', '', '', '',
'jobnum', 'int', '', '', '', '',
+ 'frozen', 'char', 'NULL', 1, '', '',
'arg', 'text', 'NULL', '', '', '',
],
'primary_key' => 'argnum',
diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm
index 381e418..1f2abe3 100644
--- a/FS/FS/queue.pm
+++ b/FS/FS/queue.pm
@@ -3,6 +3,8 @@ package FS::queue;
use strict;
use vars qw( @ISA @EXPORT_OK $DEBUG $conf $jobnums);
use Exporter;
+use MIME::Base64;
+use Storable qw( nfreeze thaw );
use FS::UID qw(myconnect);
use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh );
@@ -142,9 +144,11 @@ sub insert {
}
foreach my $arg ( @args ) {
+ my $freeze = ref($arg) ? 'Y' : '';
my $queue_arg = new FS::queue_arg ( {
'jobnum' => $self->jobnum,
- 'arg' => $arg,
+ 'frozen' => $freeze,
+ 'arg' => $freeze ? encode_base64(nfreeze($arg)) : $arg,# always freeze?
} );
$error = $queue_arg->insert;
if ( $error ) {
@@ -254,11 +258,12 @@ Returns a list of the arguments associated with this job.
sub args {
my $self = shift;
- map $_->arg, qsearch( 'queue_arg',
- { 'jobnum' => $self->jobnum },
- '',
- 'ORDER BY argnum'
- );
+ map { $_->frozen ? thaw(decode_base64($_->arg)) : $_->arg }
+ qsearch( 'queue_arg',
+ { 'jobnum' => $self->jobnum },
+ '',
+ 'ORDER BY argnum'
+ );
}
=item cust_svc
diff --git a/FS/FS/queue_arg.pm b/FS/FS/queue_arg.pm
index c96ff12..8e9a10d 100644
--- a/FS/FS/queue_arg.pm
+++ b/FS/FS/queue_arg.pm
@@ -36,6 +36,8 @@ FS::Record. The following fields are currently supported:
=item jobnum - see L<FS::queue>
+=item frozen - argument is frozen with Storable
+
=item arg - argument
=back
@@ -96,6 +98,7 @@ sub check {
my $error =
$self->ut_numbern('argnum')
|| $self->ut_numbern('jobnum')
+ || $self->ut_enum('frozen', [ '', 'Y' ])
|| $self->ut_anything('arg')
;
return $error if $error;