Koha::Plugins::call() uses get_enabled_plugins to get all enabled plugins, including plugins that do not have the method to be called. In addition, get_enabled_plugins uses can_load to evaluate plugis, but call already uses eval to call methods making the use of can_load and $plugin_class->new() superfluous and wasteful. We should filter out all enabled plugins that do not match the plugin method being called and allow the eval in call() to handle plugin error handling.
Created attachment 152699 [details] [review] Bug 34121: Filter enabled plugins for the given method
Created attachment 152700 [details] [review] Bug 34121: Do not test plugin ahead of time
Hi Kyle, As it is in master, Koha::Plugins::call runs one SQL query on the first invocation, and zero on the next invocations (thanks to Koha::Cache::Memory::Lite). With your patches, it will run 2 SQL queries on every invocations. Is it really faster ? (In reply to Kyle M Hall from comment #0) > In addition, get_enabled_plugins uses can_load to evaluate plugis, but call > already uses eval to call methods making the use of can_load and > $plugin_class->new() superfluous and wasteful. That's two different things. `get_enabled_plugins` instantiates each plugin object, while `call` uses these plugin object to invoke the plugin method. You can't invoke the plugin method without instantiating the plugin object first I can see that the patches are not finished yet, but wanted to give you an early feedback anyway. I hope that helps
> I can see that the patches are not finished yet, but wanted to give you an > early feedback anyway. I hope that helps Thanks for the feedback. I'm presuming that can_load is heavier than a query. I should test my assumptions. I also should implement caching per-method. I'm also leaning toward the the second patch being a bad idea.