Bugzilla – Attachment 118293 Details for
Bug 27557
Add the ability to display the error that caused a 500
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27557: Display stacktrace on 500 for superlibrarian
Bug-27557-Display-stacktrace-on-500-for-superlibra.patch (text/plain), 5.79 KB, created by
Jonathan Druart
on 2021-03-16 10:26:44 UTC
(
hide
)
Description:
Bug 27557: Display stacktrace on 500 for superlibrarian
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-16 10:26:44 UTC
Size:
5.79 KB
patch
obsolete
>From 7dd692699614f5843b0ab26438d085f1f892a05b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Mar 2021 11:22:17 +0100 >Subject: [PATCH] Bug 27557: Display stacktrace on 500 for superlibrarian > >From pod for Plack::Middleware::StackTrace: >""" >Gathering the information for a stack trace via Devel::StackTrace is slow, and Devel::StackTrace::WithLexicals is significantly slower still. This is not usually a concern in development and when exceptions are rare. However, your application may include code that's throwing and catching exceptions that you're not aware of. Such code will run significantly slower with this module. >""" >Maybe we should avoid the stacktrace and prefer to retrieve the error >only, without the stacktrace? (but how?) > >cp C4/Auth.pm /usr/share/koha/lib/C4/Auth.pm >cp debian/templates/plack.psgi /etc/koha/sites/kohadev/plack.psgi >cp errors/500.pl /usr/share/koha/intranet/cgi-bin/errors/500.pl >cp koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/en/modules/errors/errorpage.tt >restart_all >--- > debian/templates/plack.psgi | 1 + > errors/500.pl | 5 +++++ > .../data/mysql/atomicupdate/bug_27557.perl | 12 ++++++++++++ > .../en/modules/admin/preferences/logs.pref | 6 ++++++ > .../prog/en/modules/errors/errorpage.tt | 19 +++++++++++++++++++ > 5 files changed, 43 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_27557.perl > >diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi >index 89cd6ef48f..785e9d1df3 100644 >--- a/debian/templates/plack.psgi >+++ b/debian/templates/plack.psgi >@@ -108,6 +108,7 @@ builder { > #NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document > #NOTE: This middleware must be closer to the PSGI app than ErrorDocument > enable "HTTPExceptions"; >+ enable "StackTrace", no_print_errors => 1; > if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){ > enable 'Log4perl', category => 'plack-intranet'; > enable 'LogWarn'; >diff --git a/errors/500.pl b/errors/500.pl >index f580b45b20..5c58494b8c 100755 >--- a/errors/500.pl >+++ b/errors/500.pl >@@ -38,6 +38,11 @@ $template->param ( > admin => $admin, > errno => 500, > ); >+if ( C4::Context->preference('DumpStacktraceOn500') && C4::Context->IsSuperLibrarian ) { >+ $template->param( >+ stacktrace => $ENV{'plack.stacktrace.text'}, >+ ); >+} > my $status = '500 Internal Server Error'; > if ( C4::Auth::psgi_env() ) { > $status = '200 OK'; >diff --git a/installer/data/mysql/atomicupdate/bug_27557.perl b/installer/data/mysql/atomicupdate/bug_27557.perl >new file mode 100644 >index 0000000000..194acf132b >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_27557.perl >@@ -0,0 +1,12 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ >+ $dbh->do(q| >+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) >+ VALUES ('DumpStacktraceOn500','0', 'Display the error on 500 for superlibrarians.', 'YesNo') >+ |); >+ >+ >+ # Always end with this (adjust the bug info) >+ NewVersion( $DBversion, 27557, "Add new syspref DumpStacktraceOn500"); >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >index 490a69569d..9e25d4a45f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >@@ -110,3 +110,9 @@ Logging: > 1: Do > 0: "Don't" > - dump search query as a template parameter, requires <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=DumpTemplateVars">DumpTemplateVars</a>[interface] to be visible. >+ - >+ - pref: DumpStacktraceOn500 >+ choices: >+ 1: Do >+ 0: "Don't" >+ - display a stacktrace of the error on 500 for superlibrarians. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt >index 6cd94c19fc..2832350c68 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Error [% errno | html %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -22,6 +23,10 @@ > <li>You tried to access a page that needs authentication</li> > <li>An internal link in the client is broken and the page does not exist</li> > </ul> >+ [% IF stacktrace %] >+ <h3>Detail of the error <span id="show_error"><a href="#">[show]</a></span><span id="hide_error" style="display: none;"><a href="#">[hide]</a></span></h3> >+ <div id="stacktrace" style="display: none;"><pre>[% stacktrace %]</pre></div> >+ [% END %] > <h3>What's next?</h3> > <ul style="margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #CCC;"> > <li>Use top menu bar to navigate to another part of Koha.</li> >@@ -31,4 +36,18 @@ > </div> <!-- /.col-md-8 --> > </div> <!-- /.row --> > >+ </div> <!-- /.container-fluid --> >+ >+[% MACRO jsinclude BLOCK %] >+ <script> >+ $(document).ready(function(){ >+ $("#show_error a, #hide_error a").on("click", function(e){ >+ e.preventDefault(); >+ $("#show_error").toggle(); >+ $("#hide_error").toggle(); >+ $("#stacktrace").toggle(); >+ }); >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >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 27557
: 118293