Bug 17669: Small change to sub delete

Instead of looping through _resultset here and wrapping the results,
we should use a Koha::Objects instance. Since the method may be called
as a class method, we create an instance if needed.

Test plan:
Run t/db_dependent/Upload.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2017-03-20 08:43:32 +01:00 committed by Kyle M Hall
parent fe9a8bf973
commit 686b7d6a82

View file

@ -63,11 +63,11 @@ Parameter keep_file may be used to delete records, but keep files.
sub delete {
my ( $self, $params ) = @_;
$self = Koha::UploadedFiles->new if !ref($self); # handle class call
# We use the individual delete on each resultset record
my $err = 0;
while( my $row = $self->_resultset->next ) {
my $kohaobj = Koha::UploadedFile->_new_from_dbic( $row );
$err++ if !$kohaobj->delete( $params );
while( my $row = $self->next ) {
$err++ if !$row->delete( $params );
}
return $err==0;
}