From 91cc29669d807df27460657938d098fd2d179ad1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 21 Apr 2023 11:18:35 +0100 Subject: [PATCH] Bug 32894: Remove incorrect caching from bundle_items Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 8e2d841a2950f3cd6008f296e67c362ebfe4b954) Signed-off-by: Martin Renvoize (cherry picked from commit 946484de015c635684235746b9c71575e21cc18f) Signed-off-by: Matt Blenkinsop --- Koha/Item.pm | 11 ++--------- Koha/Schema/Result/Item.pm | 3 +++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 46b34c2477..fd02140b0e 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1625,15 +1625,8 @@ Returns the items associated with this bundle sub bundle_items { my ($self) = @_; - if ( !$self->{_bundle_items_cached} ) { - my $bundle_items = Koha::Items->search( - { 'item_bundles_item.host' => $self->itemnumber }, - { join => 'item_bundles_item' } ); - $self->{_bundle_items} = $bundle_items; - $self->{_bundle_items_cached} = 1; - } - - return $self->{_bundle_items}; + my $rs = $self->_result->bundle_items; + return Koha::Items->_new_from_dbic($rs); } =head3 is_bundle diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 9bc8bf7fbb..859fe22d30 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -978,6 +978,9 @@ __PACKAGE__->has_many( } ); +# Relationship with bundled items +__PACKAGE__->many_to_many( bundle_items => 'item_bundles_hosts', 'item' ); + __PACKAGE__->might_have( "last_returned_by", "Koha::Schema::Result::ItemsLastBorrower", -- 2.39.5