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

(-)a/debian/templates/plack.psgi (+24 lines)
Lines 78-83 builder { Link Here
78
    enable "+Koha::Middleware::RealIP";
78
    enable "+Koha::Middleware::RealIP";
79
79
80
    mount '/opac'          => builder {
80
    mount '/opac'          => builder {
81
        #NOTE: it is important that these are relative links
82
        enable 'ErrorDocument',
83
            400 => 'errors/400.pl',
84
            401 => 'errors/401.pl',
85
            402 => 'errors/402.pl',
86
            403 => 'errors/403.pl',
87
            404 => 'errors/404.pl',
88
            500 => 'errors/500.pl',
89
            subrequest => 1;
90
        #NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document
91
        #NOTE: This middleware must be closer to the PSGI app than ErrorDocument
92
        enable "HTTPExceptions";
81
        if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){
93
        if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){
82
            enable 'Log4perl', category => 'plack-opac';
94
            enable 'Log4perl', category => 'plack-opac';
83
            enable 'LogWarn';
95
            enable 'LogWarn';
Lines 85-90 builder { Link Here
85
        $opac;
97
        $opac;
86
    };
98
    };
87
    mount '/intranet'      => builder {
99
    mount '/intranet'      => builder {
100
        #NOTE: it is important that these are relative links
101
        enable 'ErrorDocument',
102
            400 => 'errors/400.pl',
103
            401 => 'errors/401.pl',
104
            402 => 'errors/402.pl',
105
            403 => 'errors/403.pl',
106
            404 => 'errors/404.pl',
107
            500 => 'errors/500.pl',
108
            subrequest => 1;
109
        #NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document
110
        #NOTE: This middleware must be closer to the PSGI app than ErrorDocument
111
        enable "HTTPExceptions";
88
        if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){
112
        if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){
89
            enable 'Log4perl', category => 'plack-intranet';
113
            enable 'Log4perl', category => 'plack-intranet';
90
            enable 'LogWarn';
114
            enable 'LogWarn';
(-)a/errors/400.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 400,
39
    errno => 400,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '400 Bad Request';
41
my $status = '400 Bad Request';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/errors/401.pl (-1 / +6 lines)
Lines 20-25 use CGI qw ( -utf8 ); Link Here
20
use C4::Auth;
20
use C4::Auth;
21
use C4::Output;
21
use C4::Output;
22
use C4::Context;
22
use C4::Context;
23
use List::MoreUtils qw(any);
23
24
24
my $query = CGI->new;
25
my $query = CGI->new;
25
my $admin = C4::Context->preference('KohaAdminEmailAddress');
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 36-39 $template->param ( Link Here
36
    admin => $admin,
37
    admin => $admin,
37
    errno => 401,
38
    errno => 401,
38
);
39
);
39
output_with_http_headers $query, $cookie, $template->output, 'html', '401 Unauthorized';
40
my $status = '401 Unauthorized';
41
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
42
    $status = '200 OK';
43
}
44
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/errors/402.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 402,
39
    errno => 402,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '402 Payment Required';
41
my $status = '402 Payment Required';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/errors/403.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 403,
39
    errno => 403,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '403 Forbidden';
41
my $status = '403 Forbidden';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/errors/404.pl (-1 / +22 lines)
Lines 18-24 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use C4::Auth;
21
use C4::Output;
22
use C4::Output;
23
use C4::Context;
24
use List::MoreUtils qw(any);
22
25
23
my $query = CGI->new;
26
my $query = CGI->new;
24
output_error( $query, '404' );
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
28
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
29
    {
30
        template_name   => 'errors/errorpage.tt',
31
        query           => $query,
32
        type            => 'intranet',
33
        authnotrequired => 1,
34
        debug           => 1,
35
    }
36
);
37
$template->param (
38
    admin => $admin,
39
    errno => 404,
40
);
41
my $status = '404 Not Found';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/errors/500.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 500,
39
    errno => 500,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '500 Internal Server Error';
41
my $status = '500 Internal Server Error';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/400.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 400,
39
    errno => 400,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '400 Bad Request';
41
my $status = '400 Bad Request';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/401.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 401,
39
    errno => 401,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '401 Unauthorized';
41
my $status = '401 Unauthorized';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/402.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 402,
39
    errno => 402,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '402 Payment Required';
41
my $status = '402 Payment Required';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/403.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 403,
39
    errno => 403,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '403 Forbidden';
41
my $status = '403 Forbidden';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/404.pl (-1 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 404,
39
    errno => 404,
39
);
40
);
40
output_html_with_http_headers $query, $cookie, $template->output, '404 Not Found';
41
my $status = '404 Not Found';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
(-)a/opac/errors/500.pl (-2 / +6 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use List::MoreUtils qw(any);
24
25
25
my $query = CGI->new;
26
my $query = CGI->new;
26
my $admin = C4::Context->preference('KohaAdminEmailAddress');
27
my $admin = C4::Context->preference('KohaAdminEmailAddress');
Lines 37-40 $template->param ( Link Here
37
    admin => $admin,
38
    admin => $admin,
38
    errno => 500,
39
    errno => 500,
39
);
40
);
40
output_with_http_headers $query, $cookie, $template->output, 'html', '500 Internal Server Error';
41
my $status = '500 Internal Server Error';
42
if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
43
    $status = '200 OK';
44
}
45
output_with_http_headers $query, $cookie, $template->output, 'html', $status;
41
- 

Return to bug 26048