Bugzilla – Attachment 110186 Details for
Bug 26470
itemnumber not available for plugin hook
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26470: Store the item before calling the after action hook
Bug-26470-Store-the-item-before-calling-the-after-.patch (text/plain), 2.72 KB, created by
Martin Renvoize (ashimema)
on 2020-09-16 12:24:25 UTC
(
hide
)
Description:
Bug 26470: Store the item before calling the after action hook
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-09-16 12:24:25 UTC
Size:
2.72 KB
patch
obsolete
>From ccc6f20503fae32668168c502edf300005a1df3a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 15 Sep 2020 16:23:05 -0300 >Subject: [PATCH] Bug 26470: Store the item before calling the after action > hook > >This patch makes Koha::Item->store call $self->SUPER::store before >calling the hook, so things like the itemnumber (AUTO_INCREMENT field) >are available to the plugin hook. > >It does so by storing the output on a temporary variable, to keep the >current behaviour of just returning the output from SUPER::store. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t \ > t/db_dependent/Koha/Item.t \ > t/db_dependent/Koha/Items.t >=> FAIL: the hooks tests fail. Item.t hasn't been altered so should pass >3. Apply this patch >4. Repeat 2. >=> SUCCESS: Tests pass! Item.t as well! (i.e. no behaviour change) >5. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 8dffac4db5..8b7a12653f 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -88,7 +88,9 @@ sub store { > $self->itype($self->biblio->biblioitem->itemtype); > } > >- my $today = dt_from_string; >+ my $today = dt_from_string; >+ my $plugin_action = 'create'; >+ > unless ( $self->in_storage ) { #AddItem > unless ( $self->permanent_location ) { > $self->permanent_location($self->location); >@@ -117,10 +119,10 @@ sub store { > logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" ) > if $log_action && C4::Context->preference("CataloguingLog"); > >- $self->_after_item_action_hooks({ action => 'create' }); >- > } else { # ModItem > >+ $plugin_action = 'modify'; >+ > my %updated_columns = $self->_result->get_dirty_columns; > return $self->SUPER::store unless %updated_columns; > >@@ -190,8 +192,6 @@ sub store { > C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ) > unless $params->{skip_modzebra_update}; > >- $self->_after_item_action_hooks({ action => 'modify' }); >- > logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) ) > if $log_action && C4::Context->preference("CataloguingLog"); > } >@@ -200,7 +200,10 @@ sub store { > $self->dateaccessioned($today); > } > >- return $self->SUPER::store; >+ my $result = $self->SUPER::store; >+ $self->get_from_storage->_after_item_action_hooks({ action => $plugin_action }); >+ >+ return $result; > } > > =head3 delete >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26470
:
110119
|
110120
|
110134
|
110135
|
110185
| 110186