From 7054edf183dade99e6819b6c063dc34ccaf25a8c Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Mon, 23 Oct 2023 17:49:06 +0200 Subject: [PATCH] Bug 35133: Don't lazily define accessor methods when invoked through SUPER To test: 1) Apply Bug 32476 2) Run tests in t/db_dependent/Patrons.t 3) This should produce multiple "Subroutine Koha::Patron::SUPER::dateexpiry redefined at ..." warnings 4) Apply patch 5) Run tests in t/db_dependent/Patrons.t again 6) The warnings in 3) should now no longer appear Signed-off-by: matthias le gac Signed-off-by: Phan Tung Bui Signed-off-by: Emily Lamancusa Signed-off-by: Katrin Fischer --- Koha/Object.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index 560dccaff2..3bab1c8e2c 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -951,8 +951,13 @@ sub AUTOLOAD { return $self->_result()->get_column($method); } }; - no strict 'refs'; ## no critic (strict) - *{$AUTOLOAD} = $accessor; + # If called from child class as $self->SUPER-> + # $AUTOLOAD will contain ::SUPER which breaks method lookup + # therefore we cannot write those entries into the symbol table + unless ( $AUTOLOAD =~ /::SUPER::/ ) { + no strict 'refs'; ## no critic (strict) + *{$AUTOLOAD} = $accessor; + } return $accessor->( $self, @_ ); } -- 2.39.5