https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42879
--- Comment #1 from Martin Renvoize (ashimema) <[email protected]> --- Created attachment 200642 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200642&action=edit Bug 42879: Avoid per-record plugin lookup in ES marc_records_to_documents Before this patch, Koha::Plugins->call('elasticsearch_to_document', ...) was invoked once per record inside the foreach loop in marc_records_to_documents(). Each call internally invokes GetPlugins() to discover which plugins implement the hook, which queries the plugin_data table. This discovery query runs N times for N records, even when zero plugins implement the hook or plugins are disabled. After this patch, the elasticsearch_to_document plugins are resolved once per batch (before the per-record loop) using Koha::Plugins->new()->GetPlugins() with a method filter. The result is cached in a boolean flag. The per-record Koha::Plugins->call() is now guarded by that flag, so: 1. When plugins are disabled (Koha::Plugins->new returns undef), no lookup occurs. 2. When no plugins implement the hook, GetPlugins() is called once (not N times). 3. When plugins exist, the same call path is used, preserving all existing behavior. Variant implemented: SAFE minimal approach - Compute a single boolean flag $has_elasticsearch_plugins before the loop - Only invoke Koha::Plugins->call() when the flag is true - This avoids per-record plugin discovery for the common (no-plugin) case - The proven call path is preserved when plugins are present Test plan: 1. Verify marc_records_to_documents produces correct document output (existing tests) 2. Run prove t/db_dependent/Koha/SearchEngine/Elasticsearch.t to ensure all subtests pass 3. Verify with KTD: index a batch of records and confirm correct Elasticsearch documents 4. Optionally: enable a test plugin with elasticsearch_to_document hook and verify it is still invoked -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
