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

(-)a/debian/templates/apache-shared-intranet-plack.conf (+1 lines)
Lines 12-17 Link Here
12
        # FIXME: These scripts should be fixed so they
12
        # FIXME: These scripts should be fixed so they
13
        # don't break under plack/starman
13
        # don't break under plack/starman
14
        ProxyPass "/cgi-bin/koha/tools/export.pl" "!"
14
        ProxyPass "/cgi-bin/koha/tools/export.pl" "!"
15
        ProxyPass "/cgi-bin/koha/tools/inventory.pl" "!"
15
        ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!"
16
        ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!"
16
        ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
17
        ProxyPass "/cgi-bin/koha/svc/cataloguing/metasearch" "!"
17
18
(-)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 377-387 if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ Link Here
377
    eval {use Text::CSV ();};
395
    eval {use Text::CSV ();};
378
    my $csv = Text::CSV->new or
396
    my $csv = Text::CSV->new or
379
            die Text::CSV->error_diag ();
397
            die Text::CSV->error_diag ();
380
    binmode STDOUT, ":encoding(UTF-8)";
381
    print $input->header(
382
        -type       => 'text/csv',
383
        -attachment => 'inventory.csv',
384
    );
385
398
386
    my $columns = Koha::Database::Columns->columns;
399
    my $columns = Koha::Database::Columns->columns;
387
    my @translated_keys;
400
    my @translated_keys;
Lines 438-444 if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ Link Here
438
    exit;
451
    exit;
439
}
452
}
440
453
441
output_html_with_http_headers $input, $cookie, $template->output;
454
#NOTE: This is a workaround until we can refactor inventory to run in the background
455
#NOTE: Output headers earlier so that we can send data out progressively to keep alive
456
#long running operations
457
#output_html_with_http_headers $input, $cookie, $template->output;
458
my $data = $template->output;
459
$data =~ s/\&amp\;amp\; /\&amp\; /g;
460
print $data;
442
461
443
sub additemtoresults {
462
sub additemtoresults {
444
    my ( $item, $results ) = @_;
463
    my ( $item, $results ) = @_;
Lines 458-460 sub additemtoresults { Link Here
458
    # since the script appends to $item, we can just overwrite the hash entry
477
    # since the script appends to $item, we can just overwrite the hash entry
459
    $results->{$itemno} = $item;
478
    $results->{$itemno} = $item;
460
}
479
}
461
- 
480
481
#NOTE: Print data to client so proxies don't time out
482
sub keep_alive {
483
    my $current_time = time();
484
    my $elapsed = $current_time - $keep_alive_start;
485
    #Only print a keep alive once every 5 seconds
486
    if ( $elapsed >= 5 ){
487
        print chr(0);
488
        #Reset variable for comparing time elapsed
489
        $keep_alive_start = $current_time;
490
   }
491
}

Return to bug 31744