This patch adds a few more hooks and extensions to an existing hook. The existing hook "after_hold_action" has been extended with the following actions: * "transfer" for when a Hold calls "set_transfer()". * "waiting" for when a Hold calls "set_waiting()". * "processing" for when a Hold calls "set_processing()". A new hook "after_account_action" is added with action "add_credit" for when credit is added via for example PAYMENT or WRITEOFF. This is consistent with when UpdateStats is called so that a plugin can be used to log the same kind of data as the normal statistics. Another new hook "after_recall_action" with action "add_recall" is also added. Also to stay consistent with the UpdateStats usage. Lastly a hook "before_index_action" with action "update" is added for the Elasticsearch::Indexer function "update_index()" so that the records being indexed can be modified before indexing. This allows for a plugin to add metadata to index or tweak or change it to provide better search results without changing the actual records (something that might be prohibited or discouraged due to centralised cataloging). Tests are provided in the patch.
Created attachment 141602 [details] [review] Bug 31734: Extend hooks for plugins Hooks added: after_account_action / add in Koha::Account::add_credit when adding credit for payment or writeoff. after_hold_action / transfer, waiting and processing in Koha::Hold::set_* after_recall_action / add in Koha::Recalls::add_recall when adding recall before_index_action / update in Koha::SearchEngine::Elasticsearch::Indexer::update_index before actually updating the index Tests added for all new hooks. How to test: 1) Run tests in t/db_dependent/Koha/Plugins/Account_hooks.t 2) Run tests in t/db_dependent/Koha/Plugins/Elasticsearch_Indexer_hooks.t 3) Run tests in t/db_dependent/Koha/Plugins/Holds_hooks.t 4) Run tests in t/db_dependent/Koha/Plugins/Recall_hooks.t Sponsored by: Gothenburg University Library
Hi Stefan, in general it's recommended to break up work into smaller granular features. They usually go in much faster, the smaller the change is, as a question or problem doesn't cause a hold up so easily. In this case, I think it would have made sense to have separate bugs for holds, accounts, indexing and recalls.
I didn't see this as that big of a thing, but ok. There are now the bugs: Bug 31894 (Hold) Bug 31895 (Account) Bug 31896 (Recall) Bug 31897 (Index) I guess this one can be closed then. Should it just be set to resolved, or is there another procedure?
Hi Stefan it looks like the bugs are progressing nicely now :) I have linked them to this bug in a way we do for 'omnibus' bugs, that combine several issues about a topic. Could you please update the wiki page for hooks when these are pushed? https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks Thanks!
I've updated the wiki with some basic information, but couldn't provide the full descriptions.
Only bug 31897 is missing here now!