From 9f64bfef652922b7b546a12290805710acbeed08 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 1 Aug 2009 19:16:47 +0000 Subject: [PATCH] support broader array of queue args #5855, fallout from #5495 --- FS/FS/Schema.pm | 1 + FS/FS/queue.pm | 17 +++++++++++------ FS/FS/queue_arg.pm | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 15adba3ed..80aed8297 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 381e418c9..1f2abe3ae 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 c96ff1236..8e9a10d28 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 +=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; -- 2.11.0