From 2d4ab2e1bc3a3a57173953317959f79a6f62ddd9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 15 May 2024 16:13:04 -0300 Subject: [PATCH] Bug 36873: Make Koha::Objects->delete pass parameters to the underlying method This patch makes the generic method pass any parameters it got passed to the underlying `delete()` method. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Objects.t => FAIL: Tests fail, parameters are not passed 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- Koha/Objects.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index a59e5d5712..3bd1e77886 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -167,17 +167,19 @@ sub search_related { =cut sub delete { - my ($self) = @_; + my ( $self, $params ) = @_; if ( Class::Inspector->function_exists( $self->object_class, 'delete' ) ) { my $objects_deleted; - $self->_resultset->result_source->schema->txn_do( sub { - $self->reset; # If we iterated already over the set - while ( my $o = $self->next ) { - $o->delete; - $objects_deleted++; + $self->_resultset->result_source->schema->txn_do( + sub { + $self->reset; # If we iterated already over the set + while ( my $o = $self->next ) { + $o->delete($params); + $objects_deleted++; + } } - }); + ); return $objects_deleted; } -- 2.39.5