From 3da41a95ce9234e7029156f010b064446a64df7a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 25 Feb 2026 06:31:13 +0000 Subject: [PATCH] Bug 41917: (QA follow-up) Avoid extra SELECT in get_effective_rule fallback The parent itemtype fallback in get_effective_rule called $itemtype_obj->parent, which uses the DBIx::Class belongs_to relationship accessor and issues a second SELECT to load the full parent row. Only the parent's itemtype code is needed for the subsequent search, so replace it with $itemtype_obj->parent_type which goes through Koha::Object's AUTOLOAD and reads the already- fetched column value directly with no extra query. Signed-off-by: Martin Renvoize --- Koha/CirculationRules.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 37df584ceb6..9b49ee46d11 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -302,11 +302,11 @@ sub get_effective_rule { my $itemtype_obj = Koha::ItemTypes->find($itemtype); return $rule unless $itemtype_obj; - my $parent = $itemtype_obj->parent; - return $rule unless $parent; + my $parent_type = $itemtype_obj->parent_type; + return $rule unless $parent_type; my $parent_search = {%$search_params}; - $parent_search->{itemtype} = [ $parent->itemtype, undef ]; + $parent_search->{itemtype} = [ $parent_type, undef ]; my $parent_rule = $self->search( $parent_search, -- 2.53.0