[Koha-patches] [PATCH] Stage Marc Import always dies if not runinbackground

Michael Hafen mdhafen at washk12.org
Tue May 27 20:14:22 CEST 2008


the callbacks shouldn't return (invalid) functions when there is not a background job.

Signed-off-by: Michael Hafen <mdhafen at washk12.org>
---
 tools/stage-marc-import.pl |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl
index 9c09d8c..11e279b 100755
--- a/tools/stage-marc-import.pl
+++ b/tools/stage-marc-import.pl
@@ -194,20 +194,26 @@ exit 0;
 sub staging_progress_callback {
     my $job = shift;
     my $dbh = shift;
-    return sub {
-        my $progress = shift;
-        $job->progress($progress);
-        $dbh->commit();
+
+    if ( $job ) {
+        return sub {
+            my $progress = shift;
+            $job->progress($progress);
+            $dbh->commit();
+        }
     }
 }
 
 sub matching_progress_callback {
     my $job = shift;
     my $dbh = shift;
-    my $start_progress = $job->progress();
-    return sub {
-        my $progress = shift;
-        $job->progress($start_progress + $progress);
-        $dbh->commit();
+
+    if ( $job ) {
+	my $start_progress = $job->progress();
+	return sub {
+	    my $progress = shift;
+	    $job->progress($start_progress + $progress);
+	    $dbh->commit();
+	}
     }
 }
-- 
1.5.4.3




More information about the Koha-patches mailing list