Bug 41918: (QA follow-up) Degrade gracefully without PROCESS privilege
Koha::Reports->running queries information_schema.processlist. A MySQL user without the PROCESS privilege still sees its own threads, but if the privilege check fails entirely (or the engine returns an unexpected error) the previous code would let the DBI exception bubble up and abort the calling report run. Wrap the selectall in eval and on failure log via Koha::Logger and treat the result as empty. This means a misconfigured database degrades to "no enforcement" rather than to "no reports can be run", matching the principle that the duplicate-running guard is a safeguard, not a critical path. The POD now documents this fallback so future readers know the empty resultset has two possible meanings: nothing is currently running, or we could not look. The Koha::Logger->warn ensures the latter is still observable in the configured log destination. Test plan: 1) prove t/db_dependent/Koha/Reports.t still passes. 2) Optional: revoke SELECT on information_schema.processlist for the koha DB user, run a report, observe a warning in the logs and the report still executes (with no duplicate enforcement). Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
521ddaacad
commit
081e895ccb
|
|
@ -18,6 +18,7 @@ package Koha::Reports;
|
|||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Logger;
|
||||
|
||||
use Koha::Report;
|
||||
|
||||
|
|
@ -51,6 +52,11 @@ Both C<user_id> (a borrowernumber) and C<report_id> are optional. The lookup
|
|||
relies on the SQL comment embedded by L<Koha::Report/prep_report> being
|
||||
visible in C<information_schema.processlist>.
|
||||
|
||||
If the database user lacks the privileges needed to query
|
||||
C<information_schema.processlist>, the failure is logged via C<warn> and
|
||||
an empty resultset is returned so that callers degrade gracefully rather
|
||||
than aborting the operation they were guarding.
|
||||
|
||||
=cut
|
||||
|
||||
sub running {
|
||||
|
|
@ -74,8 +80,12 @@ sub running {
|
|||
my $sql = 'SELECT info FROM information_schema.processlist WHERE ' . join( ' AND ', @where );
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
my $rows =
|
||||
$schema->storage->dbh->selectall_arrayref( $sql, { Slice => {} }, @binds );
|
||||
my $rows;
|
||||
eval { $rows = $schema->storage->dbh->selectall_arrayref( $sql, { Slice => {} }, @binds ); };
|
||||
if ($@) {
|
||||
Koha::Logger->get->warn("Koha::Reports->running: unable to query information_schema.processlist: $@");
|
||||
$rows = [];
|
||||
}
|
||||
|
||||
my %report_ids;
|
||||
for my $row (@$rows) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue