From 22f8584eadd2ace33f296f9cee1409ed6608e12b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Aug 2019 18:27:30 -0500 Subject: [PATCH] Bug 23463: build cn_sort only if needed No need to calculate cn_sort if not dirty when we store Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- Koha/Item.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index c760e05889..bb08653702 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -76,7 +76,8 @@ sub store { $self->itype($self->biblio->biblioitem->itemtype); } - if ( $self->itemcallnumber ) { # This could be improved, we should recalculate it only if changed + my %updated_columns = $self->_result->get_dirty_columns; + if ( exists $updated_columns{itemcallnumber} ) { my $cn_sort = GetClassSort($self->cn_source, $self->itemcallnumber, ""); $self->cn_sort($cn_sort); } @@ -135,7 +136,7 @@ sub store { } } - my %updated_columns = $self->_result->get_dirty_columns; + %updated_columns = $self->_result->get_dirty_columns; return $self->SUPER::store unless %updated_columns; if ( exists $updated_columns{location} and $self->location ne 'CART' -- 2.39.5