From 918fbc24f7a1b628d371d7f6c9ae89f2f42ac01e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Dec 2023 09:27:45 +0100 Subject: [PATCH] Bug 34478: Display programming errors in case plack.psgi caught something suspicious It will help developpers to debug the problematic places. Signed-off-by: Jonathan Druart --- C4/Auth.pm | 8 ++++++++ debian/templates/plack.psgi | 4 +++- koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 51eef1e1be..4cf7f7659b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -477,6 +477,14 @@ sub get_template_and_user { OPACBaseURL => C4::Context->preference('OPACBaseURL'), minPasswordLength => $minPasswordLength, ); + if ( C4::Context->config('dev_install') ) { + # Dealing with debug_programming_error ( set from plack.psgi) + $template->param( + dev_install => 1, + debug_programming_error => scalar $in->{query}->param('debug_programming_error'), + ); + $in->{query}->delete('debug_programming_error'); + } if ( $in->{'type'} eq "intranet" ) { $template->param( diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index eadb17204f..4448a781e7 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -51,11 +51,13 @@ use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise my $original_op = $q->param('op'); my $request_method = $q->request_method // q{}; if ( $request_method eq 'GET' && defined $original_op && $original_op =~ m{^cud-} ) { - warn "Programming error - op '$original_op' must not start with 'cud-' with GET"; + warn "Programming error - op '$original_op' must not start with 'cud-' for GET"; $q->param( 'op', '' ); + $q->param( 'debug_programming_error', "'$original_op' must not start with 'cud-' for GET" ); } elsif ( $request_method ne 'GET' && defined $q->param('op') && $original_op !~ m{^cud-} ) { warn "Programming error - op '$original_op' must start with 'cud-' for $request_method"; $q->param( 'op', '' ); + $q->param( 'debug_programming_error', "'$original_op' must start with 'cud-' for $request_method" ); } return $q; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc index 235fbf6ff0..3a0d205ddd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc @@ -1 +1,4 @@ [% INCLUDE 'blocking_errors.inc' %] +[% IF dev_install && debug_programming_error %] +
Programming error: [% debug_programming_error %]
+[% END %] -- 2.39.5