Bug 25303: Call ->reset before iterate on the set
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 30 Apr 2020 11:24:30 +0000 (13:24 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 1 May 2020 07:08:09 +0000 (08:08 +0100)
In case we already started to iterate.

This fixes a failing tests in t/db_dependent/Koha/Biblios.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Objects.pm

index b9697dc17bfd2ce2c44f22fd86b04b15e826a0d7..eb77c0e0e6c8824a55c69f9436ebb2d8306a827e 100644 (file)
@@ -182,6 +182,7 @@ sub delete {
     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++;