Bug 39160 - Mojolicious::Plugin::OAuth2 is loaded suboptimally
Summary: Mojolicious::Plugin::OAuth2 is loaded suboptimally
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-19 02:26 UTC by David Cook
Modified: 2025-02-19 06:01 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39160: Use optimal Mojolicious plugin name (1.05 KB, patch)
2025-02-19 06:00 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-02-19 02:26:23 UTC
This is a deep cut, but the following line is not optimal:
$self->plugin( 'Mojolicious::Plugin::OAuth2' => $oauth_configuration );

Mojolicious will first try to load that as Mojolicious::Plugin::Mojolicious::Plugin::OAuth2 before it realises that we've already loaded Mojolicious::Plugin::OAuth2 earlier in Koha::REST::V1.

I reckon that should say:
$self->plugin( 'OAuth2' => $oauth_configuration );

--

In the grand scheme of things, it's not a big deal, but we can save ourselves 26 system calls by changing 1 line.
Comment 1 David Cook 2025-02-19 06:00:01 UTC
Created attachment 178304 [details] [review]
Bug 39160: Use optimal Mojolicious plugin name

This change uses "OAuth2" instead of "Mojolicious::Plugin::OAuth2"
when setting the plugin, so that Mojolicious can find the plugin
faster.

Test plan:
0. Apply the patch
1. koha-plack --restart kohadev
2. Run through "Testing SSO" from the Koha Wiki
3. Confirm that you can log into Koha using the Keycloak OIDC
Comment 2 David Cook 2025-02-19 06:01:36 UTC
If you *really* want to confirm this does what I say it does, you're going to have to use "strace" to examine the kernel syscalls the starman worker is making when it starts up.

Specifically, you'll be looking to make sure that it doesn't do things like this:
newfstatat(AT_FDCWD, "/usr/local/lib/site_perl/Mojolicious/Plugin/Mojolicious/Plugin/OAuth2.pm", 0x7ffd205204e0, 0) = -1 ENOENT (No such file or directory)