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 <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 2d4ab2e1bc)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
cf05d5d43a
commit
f49de36e81
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue