View | Details | Raw Unified | Return to bug 31744
Collapse All | Expand All

(-)a/debian/templates/apache-shared-intranet-plack.conf (+1 lines)
Lines 14-19 Link Here
14
        ProxyPass "/cgi-bin/koha/offline_circ/process_koc.pl" "!"
14
        ProxyPass "/cgi-bin/koha/offline_circ/process_koc.pl" "!"
15
        ProxyPass "/cgi-bin/koha/tools/background-job-progress.pl" "!"
15
        ProxyPass "/cgi-bin/koha/tools/background-job-progress.pl" "!"
16
        ProxyPass "/cgi-bin/koha/tools/export.pl" "!"
16
        ProxyPass "/cgi-bin/koha/tools/export.pl" "!"
17
        ProxyPass "/cgi-bin/koha/tools/inventory.pl" "!"
17
        ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!"
18
        ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!"
18
        ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
19
        ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
19
20
(-)a/debian/templates/apache-shared.conf (+6 lines)
Lines 34-39 SetEnv PERL5LIB "/usr/share/koha/lib" Link Here
34
34
35
35
36
<IfModule mod_deflate.c>
36
<IfModule mod_deflate.c>
37
38
    <If "%{REQUEST_URI} == '/cgi-bin/koha/tools/inventory.pl'">
39
      #Do not compress inventory.pl response, so it can stream keep alive data
40
      #NOTE: To override AddOutputFilterByType in a higher section, you need to add a dummy directive here
41
      AddOutputFilterByType DEFLATE text/plain
42
    </If>
37
    # Compress content with type html, text, and css, ...
43
    # Compress content with type html, text, and css, ...
38
    AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
44
    AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
39
    AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
45
    AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
(-)a/tools/inventory.pl (-7 / +37 lines)
Lines 69-74 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
69
    }
69
    }
70
);
70
);
71
71
72
#NOTE: Turn off buffering so that keep alives go out ASAP
73
$|++;
74
my $keep_alive_start = time();
75
76
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
77
    binmode STDOUT, ":encoding(UTF-8)";
78
    print $input->header(
79
        -type       => 'text/csv',
80
        -attachment => 'inventory.csv',
81
    );
82
}
83
else {
84
    output_html_with_http_headers $input, $cookie, '';
85
}
86
72
my @authorised_value_list;
87
my @authorised_value_list;
73
my $authorisedvalue_categories = '';
88
my $authorisedvalue_categories = '';
74
89
Lines 192-197 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
192
        $uploadbarcodes = $barcodelist;
207
        $uploadbarcodes = $barcodelist;
193
    }
208
    }
194
    for my $barcode (@uploadedbarcodes) {
209
    for my $barcode (@uploadedbarcodes) {
210
        keep_alive();
195
        next unless $barcode;
211
        next unless $barcode;
196
212
197
        $barcode = barcodedecode($barcode);
213
        $barcode = barcodedecode($barcode);
Lines 219-224 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
219
                          err_data   => $err_data );
235
                          err_data   => $err_data );
220
    }
236
    }
221
    foreach my $barcode (@barcodes) {
237
    foreach my $barcode (@barcodes) {
238
        keep_alive();
222
        if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) {
239
        if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) {
223
            push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 };
240
            push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 };
224
        } else {
241
        } else {
Lines 299-304 if( @scanned_items ) { Link Here
299
# Report scanned items that are on the wrong place, or have a wrong notforloan
316
# Report scanned items that are on the wrong place, or have a wrong notforloan
300
# status, or are still checked out.
317
# status, or are still checked out.
301
for ( my $i = 0; $i < @scanned_items; $i++ ) {
318
for ( my $i = 0; $i < @scanned_items; $i++ ) {
319
    keep_alive();
302
320
303
    my $item = $scanned_items[$i];
321
    my $item = $scanned_items[$i];
304
322
Lines 387-397 if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ Link Here
387
    eval {use Text::CSV ();};
405
    eval {use Text::CSV ();};
388
    my $csv = Text::CSV->new or
406
    my $csv = Text::CSV->new or
389
            die Text::CSV->error_diag ();
407
            die Text::CSV->error_diag ();
390
    binmode STDOUT, ":encoding(UTF-8)";
391
    print $input->header(
392
        -type       => 'text/csv',
393
        -attachment => 'inventory.csv',
394
    );
395
408
396
    my $columns = Koha::Database::Columns->columns;
409
    my $columns = Koha::Database::Columns->columns;
397
    my @translated_keys;
410
    my @translated_keys;
Lines 448-454 if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ Link Here
448
    exit;
461
    exit;
449
}
462
}
450
463
451
output_html_with_http_headers $input, $cookie, $template->output;
464
#NOTE: This is a workaround until we can refactor inventory to run in the background
465
#NOTE: Output headers earlier so that we can send data out progressively to keep alive
466
#long running operations
467
#output_html_with_http_headers $input, $cookie, $template->output;
468
my $data = $template->output;
469
$data =~ s/\&amp\;amp\; /\&amp\; /g;
470
print $data;
452
471
453
sub additemtoresults {
472
sub additemtoresults {
454
    my ( $item, $results ) = @_;
473
    my ( $item, $results ) = @_;
Lines 456-458 sub additemtoresults { Link Here
456
    # since the script appends to $item, we can just overwrite the hash entry
475
    # since the script appends to $item, we can just overwrite the hash entry
457
    $results->{$itemno} = $item;
476
    $results->{$itemno} = $item;
458
}
477
}
459
- 
478
479
#NOTE: Print data to client so proxies don't time out
480
sub keep_alive {
481
    my $current_time = time();
482
    my $elapsed = $current_time - $keep_alive_start;
483
    #Only print a keep alive once every 5 seconds
484
    if ( $elapsed >= 5 ){
485
        print chr(0);
486
        #Reset variable for comparing time elapsed
487
        $keep_alive_start = $current_time;
488
   }
489
}

Return to bug 31744