Bug 35843 - No such thing as Koha::Exceptions::Exception
Summary: No such thing as Koha::Exceptions::Exception
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Marcel de Rooy
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on:
Blocks: 35962
  Show dependency treegraph
 
Reported: 2024-01-19 08:51 UTC by Magnus Enger
Modified: 2024-02-13 15:35 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.03,23.05.09


Attachments
Bug 35843: Correct invalid exception (3.70 KB, patch)
2024-01-19 09:40 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 35843: Correct invalid exception (3.78 KB, patch)
2024-01-19 10:09 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 35843: Correct invalid exception (3.85 KB, patch)
2024-01-23 17:18 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2024-01-19 08:51:04 UTC
On Koha 22.11.04-1 installed with the Debian packages I have some background jobs that are failing, and I see this in the logs: 

==> /var/log/koha/mykoha/plack-intranet-error.log <==
[2024/01/19 08:47:02] [WARN] The job has not been sent to the message broker: (Can't locate object method "throw" via package "Koha::Exceptions::Exception" (perhaps you forgot to load "Koha::Exceptions::Exception"?) at /usr/share/koha/lib/Koha/BackgroundJob.pm line 141.
) at /usr/share/koha/lib/Koha/BackgroundJob.pm line 148.

The relevant code looks like this: 

134     try {
135         # This namespace is wrong, it must be a vhost instead.
136         # But to do so it needs to be created on the server => much more work when a new Koha instance is created.
137         # Also, here we just want the Koha instance's name, but it's not in the config...
138         # Picking a random id (memcached_namespace) from the config
139         my $namespace = C4::Context->config('memcached_namespace');
140         my $encoded_args = Encode::encode_utf8( $json_args ); # FIXME We should better leave this to Net::Stomp?
141         $conn->send_with_receipt( { destination => sprintf("/queue/%s-%s", $namespace, $job_queue), body => $encoded_args } )
142           or Koha::Exceptions::Exception->throw('Job has not been enqueued');
143     } catch {
144         $self->status('failed')->store;
145         if ( ref($_) eq 'Koha::Exceptions::Exception' ) {
146             $_->rethrow;
147         } else {
148             warn sprintf "The job has not been sent to the message broker: (%s)", $_;
149         }
150     };

This code is the only place Koha::Exceptions::Exception is mentioned in the code:

$ sudo grep -rn "Koha::Exceptions::Exception" /usr/share/koha/
/usr/share/koha/lib/Koha/BackgroundJob.pm:142:          or Koha::Exceptions::Exception->throw('Job has not been enqueued');
/usr/share/koha/lib/Koha/BackgroundJob.pm:145:        if ( ref($_) eq 'Koha::Exceptions::Exception' ) {
Comment 1 Magnus Enger 2024-01-19 08:55:07 UTC
Looks like the code was changed from 

Koha::Exception->throw('Job has not been enqueued');

to 

Koha::Exceptions::Exception->throw('Job has not been enqueued');

by bug 30172: https://git.koha-community.org/Koha-community/Koha/commit/7585db29c08078d2b85faf27d110c4598e03881d
Comment 2 Magnus Enger 2024-01-19 09:00:37 UTC
Looks like there was Koha::Exceptions::Exception, but it was changed to Koha::Exception by bug 29857.
Comment 3 Marcel de Rooy 2024-01-19 09:40:07 UTC
Created attachment 161177 [details] [review]
Bug 35843: Correct invalid exception

Test plan:
Run background job tests. Especially the changed one.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 Magnus Enger 2024-01-19 10:09:57 UTC
Created attachment 161181 [details] [review]
Bug 35843: Correct invalid exception

Test plan:
Run background job tests. Especially the changed one.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
All test pass when running this:
prove t/db_dependent/Koha/BackgroundJobs*
Comment 5 Martin Renvoize 2024-01-23 17:18:08 UTC
Created attachment 161311 [details] [review]
Bug 35843: Correct invalid exception

Test plan:
Run background job tests. Especially the changed one.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
All test pass when running this:
prove t/db_dependent/Koha/BackgroundJobs*
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Katrin Fischer 2024-01-26 14:18:26 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 7 Fridolin Somers 2024-01-31 12:51:51 UTC
Pushed to 23.11.x for 23.11.03
Comment 8 Lucas Gass 2024-02-13 15:35:40 UTC
Backported to 23.05.x for upcoming 23.05.09