From 72479fec404ebf446f53a1c290ac10139e65d418 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 18 Sep 2013 17:23:44 +0000 Subject: [PATCH] Bug 10601: (follow-up) improvements to ->set() and ->get() This patch improves the POD for C4::BackgroundJob->get(). It also fixes ->set() so that it cannot scribble over values that are properly internal to the object. Signed-off-by: Galen Charlton --- C4/BackgroundJob.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/BackgroundJob.pm b/C4/BackgroundJob.pm index f562c8e55e..3ab5125228 100644 --- a/C4/BackgroundJob.pm +++ b/C4/BackgroundJob.pm @@ -83,6 +83,7 @@ sub new { $self->{'progress'} = 0; $self->{'status'} = "running"; $self->{'jobID'} = Digest::MD5::md5_hex(Digest::MD5::md5_hex(time().{}.rand().{}.$$)); + $self->{'extra_values'} = {}; bless $self, $class; $self->_serialize(); @@ -276,16 +277,17 @@ These variables can be retrieved using the get method. sub set { my ($self, $hashref) = @_; while ( my ($k, $v) = each %$hashref ) { - $self->{$k} = $v; + $self->{extra_values}->{$k} = $v; } $self->_serialize(); + return; } =head2 get =over 4 -=item $job->get($hashref); +=item $value = $job->get($key); =back @@ -295,7 +297,7 @@ Get a variable which has been previously stored with the set method. sub get { my ($self, $key) = @_; - return $self->{$key}; + return $self->{extra_values}->{$key}; } 1; -- 2.39.5