[Koha-bugs] [Bug 35624] New: Plugin tasks 'type' issue with plugins
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed Dec 20 23:15:25 CET 2023
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35624
Bug ID: 35624
Summary: Plugin tasks 'type' issue with plugins
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P5 - low
Component: Architecture, internals, and plumbing
Assignee: koha-bugs at lists.koha-community.org
Reporter: tomascohen at gmail.com
QA Contact: testopia at bugs.koha-community.org
When we designed the 'background jobs for plugins', we let the plugins define a
`namespace` and each of it's jobs, a `type`.
Plugins pick a name and provide a mapping to the implementing class, and then
Koha's core handling calculates a plugin-specific type, to avoid collisions, in
the form of "plugin_$namespace_$type'.
This works correctly for picking the job from the DB, which is what we probably
tested.
The problem I found is the Koha::BackgroundJob::enqueue method doesn't have
enough information to calculate the 'job_type'. For that it would need to:
* know we're talking about a plugin job
* know which plugin and/or the namespace
* know how to calculate the name
Right now, it picks the type from $self->job_ype.
The simplest workaround for this situation would be (a) to do something like:
--- a/Koha/BackgroundJob.pm
+++ b/Koha/BackgroundJob.pm
@@ -95,12 +95,12 @@ Return the job_id of the newly created job.
sub enqueue {
my ( $self, $params ) = @_;
- my $job_type = $self->job_type;
+ my $job_type = $params->{job_type} // $self->job_type;
and thus allow the plugin to deal with the calculation. The drawback being we
give too much responsibility to the plugin author and less flexibility if we
find we need to change this. I'm really not sure how bad it would be. Sounds
reasonable.
Another option would be (b) to require plugin authors to put the fully
qualified job type on their plugins [1], and get rid of doing it in
Koha::BackgroundJob::plugin_types_to_classes.
A third option would be to pass the information about the job coming from a
plugin (e.g. enqueue({ is_plugin => 1, plugin_namespage => 'kitchensink' }) and
have some internal sub to calculate the final 'type'.
Posting this to start the discussion, but I need to finish implementing plugin
jobs this week so, hurry!
[1] This is what we actually did on the KitchenSink plugin.
--
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
More information about the Koha-bugs
mailing list