Bugzilla – Attachment 115434 Details for
Bug 26048
PSGI Koha does not use custom ErrorDocument pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26048: POC - use ErrorDocument for 500
Bug-26048-POC---use-ErrorDocument-for-500.patch (text/plain), 3.16 KB, created by
Jonathan Druart
on 2021-01-20 14:15:43 UTC
(
hide
)
Description:
Bug 26048: POC - use ErrorDocument for 500
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-20 14:15:43 UTC
Size:
3.16 KB
patch
obsolete
>From f234940fa09cd657a69654fef36617a6a231ced1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 20 Jan 2021 15:13:10 +0100 >Subject: [PATCH] Bug 26048: POC - use ErrorDocument for 500 > >Proof of concept to use ErrorDocument to handle our 500. > >This is not ready at all, we need to tweak the mount and enable >statements to make it possible to have a separate 500 for OPAC and >intranet > >To test you need to: >1. Edit /usr/sbin/koha-plack >Force environment to be set to deployment >109 environment="deployment"; >2. Add a die somewhere and hit the page >--- > debian/templates/plack.psgi | 64 ++++++++++++++++++++++--------------- > 1 file changed, 39 insertions(+), 25 deletions(-) > >diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi >index 99438c595a..8bdc67347b 100644 >--- a/debian/templates/plack.psgi >+++ b/debian/templates/plack.psgi >@@ -36,9 +36,7 @@ use Koha::Caches; > use Koha::Cache::Memory::Lite; > use Koha::Database; > use Koha::DateUtils; >-use Koha::Logger; > >-use Log::Log4perl; > use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise > { > no warnings 'redefine'; >@@ -67,8 +65,6 @@ my $apiv1 = builder { > $server->to_psgi_app; > }; > >-Koha::Logger->_init; >- > builder { > enable "ReverseProxy"; > enable "Plack::Middleware::Static"; >@@ -77,25 +73,43 @@ builder { > enable "+Koha::Middleware::SetEnv"; > enable "+Koha::Middleware::RealIP"; > >- mount '/opac' => builder { >- if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){ >- enable 'Log4perl', category => 'plack-opac'; >- enable 'LogWarn'; >- } >- $opac; >- }; >- mount '/intranet' => builder { >- if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){ >- enable 'Log4perl', category => 'plack-intranet'; >- enable 'LogWarn'; >- } >- $intranet; >- }; >- mount '/api/v1/app.pl' => builder { >- if ( Log::Log4perl->get_logger('plack-api')->has_appenders ){ >- enable 'Log4perl', category => 'plack-api'; >- enable 'LogWarn'; >- } >- $apiv1; >- }; >+ enable 'ErrorDocument', 500, '/errors', subrequest => 1; >+ enable 'StackTrace', no_print_errors => 1; >+ >+ mount '/opac' => $opac; >+ mount '/intranet' => $intranet; >+ mount '/api/v1/app.pl' => $apiv1; >+ >+ mount '/errors' => sub { >+ my $env = shift; >+ >+ use CGI qw ( -utf8 ); >+ use C4::Auth; >+ use C4::Output; >+ use C4::Context; >+ >+ my $query = CGI->new; >+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => 'errors/errorpage.tt', >+ query => $query, >+ type => 'intranet', >+ authnotrequired => 1, >+ debug => 1, >+ } >+ ); >+ $template->param ( >+ errno => 500, >+ admin => C4::Context->preference('KohaAdminEmailAddress'), >+ ); >+ my $output = $template->output; >+ my $length = length($output); >+ >+ return [ >+ 200, >+ ['Content-Type' => 'text/html; charset=UTF-8', 'Content-Length' => $length], >+ [$output] >+ ]; >+ }; >+ > }; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26048
:
115434
|
115488
|
115493
|
115619
|
115682
|
115684