https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40984 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA --- Comment #10 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Martin Renvoize (ashimema) from comment #8)
Thanks Marcel, and sorry for the very late reply. I have reworked the patch (new version attached, rebased on current main) to answer your comments.
The warning (comments 2, 3 and 5): you are right, it was logged on every action as soon as any enabled plugin had the hook, whichever signature it used. It is gone. Like bug 36343 did for the biblio hooks, the deprecation is now announced once, as a warning in the database update (atomicupdate/bug_40984.pl), for plugin authors. The old authority and authority_id parameters are still passed outside of the payload, so existing plugins keep working.
Where the before hook is called (comment 4): it was too early, and your suggestion was right. In biblio the hook is called once the record has all its changes, just before it is stored. It is now called in AddAuthority after the 001 is set and before the heading is derived from the record and everything is saved. That has two advantages over the first version: the authority_id is known for a new authority too (it was undefined for a create), and a plugin that changes the heading fields gets the right heading stored, as the heading is derived after the hook.
The authority object (comment 6): both AddAuthority and DelAuthority already had the Koha::Authority object, so they now pass it to the after hook, which no longer looks it up again. The payload has authority, authority_id and record. For a delete, authority is the object of the authority that has just been deleted, so a plugin can get its authtypecode (and the rest of its details). This goes a little further than biblio, where biblio is undef for a delete. One consequence to be aware of: the deprecated authority parameter is now also that object, not undef, for a delete.
Tests: the test plugin now reports the 001 in the before hook and the authtypecode in the after hook, and t/db_dependent/Koha/Plugins/authority_hooks.t checks that the before hook gets the authority_id and a record with its 001 set for a create, and that the after hook gets the type for create, modify and delete. Against the first version of the patch the before hook test and the delete test fail, they pass now. t/db_dependent/Koha/Plugins/, AuthoritiesMarc.t, Koha/Authorities.t and Koha/Authority.t pass, and koha-qa is clean.
Setting this bug back for testing.
Thx for doing so. Looks good, just a minor note: + _before_authority_action_hooks( { action => 'save', authority_id => $authid, record => $record } ); The new before hook receives the MARC record. This looks like biblio but note that there is a difference: in ModBiblioMarc we dont have $biblio object, but in AddAuthority we do have $authority already. The variable record we do already use in Biblio. But it is a bit confusing: it is the MARC record, but we could think that it is the Koha object. Record is just too common. But we are consistent :) No blocker. No action required. Just noting. sub _after_authority_action_hooks { + payload => { + authority => $authority, + authority_id => $authority_id, + record => $record, Why do we add record to the payload here? This is not done at the biblio side in the after action. If there is an object, the plugin can easily get to it: $object->record. I would recommend to remove record here. -- You are receiving this mail because: You are watching all bug changes.