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:
parent
5b5c875df9
commit
5da8ba1ce9
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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' } );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue