Bug 42667: (QA follow-up) Fix null guard and exception description

- Add null check around Koha::Patrons->find() in guided_reports.pl
  before calling ->has_permission, matching the defensive pattern
  already used in Koha::Report::check_edit_permission
- Add missing description to Koha::Exceptions::Report base class
  for consistency with its sub-exceptions

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-06-11 16:12:52 +01:00 committed by Pedro Amorim
parent 5b5c875df9
commit 5da8ba1ce9
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 4 additions and 2 deletions

View File

@ -6,7 +6,8 @@ use Koha::Exception;
use Exception::Class ( use Exception::Class (
'Koha::Exceptions::Report' => { 'Koha::Exceptions::Report' => {
isa => 'Koha::Exception', isa => 'Koha::Exception',
description => 'A report operation failed',
}, },
'Koha::Exceptions::Report::DuplicateRunning' => { 'Koha::Exceptions::Report::DuplicateRunning' => {
isa => 'Koha::Exceptions::Report', isa => 'Koha::Exceptions::Report',

View File

@ -115,8 +115,9 @@ $template->param( templates => Koha::Notice::Templates->search( { module => 'rep
if ( $op eq 'edit_form' || $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { if ( $op eq 'edit_form' || $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) {
my $report = Koha::Reports->find( scalar $input->param('id') ); my $report = Koha::Reports->find( scalar $input->param('id') );
if ( $report && ( !$report->borrowernumber || $report->borrowernumber != $borrowernumber ) ) { if ( $report && ( !$report->borrowernumber || $report->borrowernumber != $borrowernumber ) ) {
my $patron = Koha::Patrons->find($borrowernumber);
output_and_exit( $input, $cookie, $template, 'insufficient_permission' ) output_and_exit( $input, $cookie, $template, 'insufficient_permission' )
unless Koha::Patrons->find($borrowernumber)->has_permission( { reports => 'edit_all_reports' } ); unless $patron && $patron->has_permission( { reports => 'edit_all_reports' } );
} }
} }