From 5da8ba1ce9509d21b9644fa27422fd3dc90e2fb9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 11 Jun 2026 16:12:52 +0100 Subject: [PATCH] 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 Signed-off-by: Pedro Amorim --- Koha/Exceptions/Report.pm | 3 ++- reports/guided_reports.pl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Exceptions/Report.pm b/Koha/Exceptions/Report.pm index 882484b86e..51a6482df8 100644 --- a/Koha/Exceptions/Report.pm +++ b/Koha/Exceptions/Report.pm @@ -6,7 +6,8 @@ use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Report' => { - isa => 'Koha::Exception', + isa => 'Koha::Exception', + description => 'A report operation failed', }, 'Koha::Exceptions::Report::DuplicateRunning' => { isa => 'Koha::Exceptions::Report', diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 124f53e29d..913e955c26 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -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' ) { my $report = Koha::Reports->find( scalar $input->param('id') ); if ( $report && ( !$report->borrowernumber || $report->borrowernumber != $borrowernumber ) ) { + my $patron = Koha::Patrons->find($borrowernumber); 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' } ); } }