]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 706412 - make JobQueue.pm support insertion of Job objects, and also enable prior...
authorGervase Markham <gerv@gerv.net>
Wed, 11 Apr 2012 08:37:07 +0000 (09:37 +0100)
committerGervase Markham <gerv@mozilla.org>
Wed, 11 Apr 2012 08:37:07 +0000 (09:37 +0100)
Bugzilla/JobQueue.pm

index ceea538095a40b926134cfd090ef353dbd2ce1fa..f8bd6a615e9fafb32c3b93205133ce1a798af669 100644 (file)
@@ -53,6 +53,7 @@ sub new {
             prefix => 'ts_',
         }],
         driver_cache_expiration => DRIVER_CACHE_TIME,
+        prioritize => 1,
     );
 
     return $self;
@@ -70,12 +71,19 @@ sub insert {
     my $self = shift;
     my $job = shift;
 
-    my $mapped_job = Bugzilla::JobQueue->job_map()->{$job};
-    ThrowCodeError('jobqueue_no_job_mapping', { job => $job })
-        if !$mapped_job;
-    unshift(@_, $mapped_job);
+    if (!ref($job)) {
+        my $mapped_job = Bugzilla::JobQueue->job_map()->{$job};
+        ThrowCodeError('jobqueue_no_job_mapping', { job => $job })
+            if !$mapped_job;
 
-    my $retval = $self->SUPER::insert(@_);
+        $job = new TheSchwartz::Job(
+            funcname => $mapped_job,
+            arg      => $_[0],
+            priority => $_[1] || 5
+        );
+    }
+    
+    my $retval = $self->SUPER::insert($job);
     # XXX Need to get an error message here if insert fails, but
     # I don't see any way to do that in TheSchwartz.
     ThrowCodeError('jobqueue_insert_failed', { job => $job, errmsg => $@ })