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

(-)a/debian/templates/plack.psgi (-1 / +20 lines)
Lines 76-83 builder { Link Here
76
    # + is required so Plack doesn't try to prefix Plack::Middleware::
76
    # + is required so Plack doesn't try to prefix Plack::Middleware::
77
    enable "+Koha::Middleware::SetEnv";
77
    enable "+Koha::Middleware::SetEnv";
78
    enable "+Koha::Middleware::RealIP";
78
    enable "+Koha::Middleware::RealIP";
79
80
    mount '/opac'          => builder {
79
    mount '/opac'          => builder {
80
        #NOTE: it is important that these are relative links
81
        enable 'ErrorDocument',
82
            400 => 'errors/400.pl',
83
            401 => 'errors/401.pl',
84
            402 => 'errors/402.pl',
85
            403 => 'errors/403.pl',
86
            404 => 'errors/404.pl',
87
            500 => 'errors/500.pl',
88
            subrequest => 1;
89
        enable 'StackTrace', no_print_errors => 1; #NOTE: StackTrace must follow ErrorDocument or 500 won't work
81
        if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){
90
        if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){
82
            enable 'Log4perl', category => 'plack-opac';
91
            enable 'Log4perl', category => 'plack-opac';
83
            enable 'LogWarn';
92
            enable 'LogWarn';
Lines 85-90 builder { Link Here
85
        $opac;
94
        $opac;
86
    };
95
    };
87
    mount '/intranet'      => builder {
96
    mount '/intranet'      => builder {
97
        #NOTE: it is important that these are relative links
98
        enable 'ErrorDocument',
99
            400 => 'errors/400.pl',
100
            401 => 'errors/401.pl',
101
            402 => 'errors/402.pl',
102
            403 => 'errors/403.pl',
103
            404 => 'errors/404.pl',
104
            500 => 'errors/500.pl',
105
            subrequest => 1;
106
        enable 'StackTrace', no_print_errors => 1; #NOTE: StackTrace must follow ErrorDocument or 500 won't work
88
        if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){
107
        if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){
89
            enable 'Log4perl', category => 'plack-intranet';
108
            enable 'Log4perl', category => 'plack-intranet';
90
            enable 'LogWarn';
109
            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