LP 1444130: Add max_chunk_size guards to Holds.pm.
authorJason Stephenson <jstephenson@mvlc.org>
Tue, 14 Apr 2015 14:43:49 +0000 (10:43 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 27 Apr 2015 15:01:50 +0000 (11:01 -0400)
Web staff client fixes introduced a bug in using the Clear
Holds Shelf checkin modifier.  Commit 4ccbf980 added calls
to max_chunk_size on the client to use chunked responses for
better feedback during long operations.  Thise works just
fine when a regular OpenSRF AppRequest is used, but leads to
a network error when AppSubrequest is used, as apparently the
xul client does with the Clear Holds Shelf checkin modifier.

This commit adds code to check if the client object can do
the max_chunk_size call when the max_chunk_size call is
made.  This will prevent the network errors in cases where
the client is an AppSubrequest object and will still use
chunked responses when the client is capable of doing it.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 144098e..a859f11 100644 (file)
@@ -1687,7 +1687,7 @@ sub print_hold_pull_list_stream {
     delete($$params{chunk_size}) unless (int($$params{chunk_size}));
     delete($$params{chunk_size}) if  ($$params{chunk_size} && $$params{chunk_size} > 50); # keep the size reasonable
     $$params{chunk_size} ||= 10;
-    $client->max_chunk_size($$params{chunk_size});
+    $client->max_chunk_size($$params{chunk_size}) if ($client->can('max_chunk_size'));
 
     $$params{org_id} = (defined $$params{org_id}) ? $$params{org_id}: $e->requestor->ws_ou;
     return $e->die_event unless $e->allowed('VIEW_HOLD', $$params{org_id });
@@ -3516,7 +3516,7 @@ sub clear_shelf_cache {
     return $e->die_event unless $e->checkauth and $e->allowed('VIEW_HOLD');
 
     $chunk_size ||= 25;
-    $client->max_chunk_size($chunk_size);
+    $client->max_chunk_size($chunk_size) if ($client->can('max_chunk_size'));
 
     my $hold_data = OpenSRF::Utils::Cache->new('global')->get_cache($cache_key);
 
@@ -3627,7 +3627,7 @@ sub clear_shelf_process {
     my @holds;
     my @canceled_holds; # newly canceled holds
     $chunk_size ||= 25; # chunked status updates
-    $client->max_chunk_size($chunk_size);
+    $client->max_chunk_size($chunk_size) if ($client->can('max_chunk_size'));
 
     my $counter = 0;
     for my $hold_id (@hold_ids) {