Bugzilla – Attachment 191341 Details for
Bug 30803
output_error should not assume a 404 status
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30803: Raise exception if $error is not passed
c67a6a9.patch (text/plain), 1.88 KB, created by
Jonathan Druart
on 2026-01-13 09:14:32 UTC
(
hide
)
Description:
Bug 30803: Raise exception if $error is not passed
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2026-01-13 09:14:32 UTC
Size:
1.88 KB
patch
obsolete
>From c67a6a960bc366eca0121dbdf4bdea43a4f28a3e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 13 Jan 2026 10:14:03 +0100 >Subject: [PATCH] Bug 30803: Raise exception if $error is not passed > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Output.pm | 5 +++++ > t/Output.t | 12 +++++++++++- > 2 files changed, 16 insertions(+), 1 deletion(-) > >diff --git a/C4/Output.pm b/C4/Output.pm >index e7d968cf050..f1d069c033a 100644 >--- a/C4/Output.pm >+++ b/C4/Output.pm >@@ -45,6 +45,7 @@ use URI::Escape; > use C4::Auth qw( get_template_and_user ); > use C4::Context; > use C4::Templates; >+use Koha::Exceptions; > > =head1 NAME > >@@ -392,6 +393,10 @@ Missing POD for output_error. > > sub output_error { > my ( $query, $error ) = @_; >+ >+ if ( !$error || $error =~ /\D/ ) { >+ Koha::Exceptions::WrongParameter->throw('output_error requires $error to be an integer'); >+ } > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => 'errors/errorpage.tt', >diff --git a/t/Output.t b/t/Output.t >index 3c022a3fab2..a3a5722a7aa 100755 >--- a/t/Output.t >+++ b/t/Output.t >@@ -20,6 +20,7 @@ use Modern::Perl; > use Test::NoWarnings; > use Test::More tests => 10; > use Test::Warn; >+use Test::Exception; > use Test::MockModule; > > use File::Temp qw/tempfile/; >@@ -139,7 +140,7 @@ subtest 'output_and_exit_if_error() tests' => sub { > }; > > subtest 'output_error' => sub { >- plan tests => 2; >+ plan tests => 4; > > local *STDOUT; > my $stdout; >@@ -158,4 +159,13 @@ subtest 'output_error' => sub { > like( $stdout, qr{Error 403}, '403 returned' ); > close STDOUT; > >+ throws_ok { >+ output_error($query); >+ } >+ 'Koha::Exceptions::WrongParameter'; >+ >+ throws_ok { >+ output_error( $query, "Error" ); >+ } >+ 'Koha::Exceptions::WrongParameter'; > }; >-- >2.43.0 >
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 30803
:
191332
|
191339
|
191340
| 191341