Bug 10601: (follow-up) improvements to ->set() and ->get()
authorGalen Charlton <gmc@esilibrary.com>
Wed, 18 Sep 2013 17:23:44 +0000 (17:23 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 18 Sep 2013 17:23:44 +0000 (17:23 +0000)
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 <gmc@esilibrary.com>
C4/BackgroundJob.pm

index f562c8e..3ab5125 100644 (file)
@@ -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;