Bug 17501: Use Koha::Object in Koha::Upload::_register
The _register routine basically inserts a new record in uploaded_files. It should use Koha::UploadedFile now. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file via Tools/Upload. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> 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:
parent
44d4dc7040
commit
44c4b3fca6
|
|
@ -75,6 +75,7 @@ use base qw(Class::Accessor);
|
|||
|
||||
use C4::Context;
|
||||
use C4::Koha;
|
||||
use Koha::UploadedFile;
|
||||
|
||||
__PACKAGE__->mk_ro_accessors( qw|| );
|
||||
|
||||
|
|
@ -365,22 +366,17 @@ sub _done {
|
|||
|
||||
sub _register {
|
||||
my ( $self, $filename, $size ) = @_;
|
||||
my $dbh= C4::Context->dbh;
|
||||
my $sql= 'INSERT INTO uploaded_files (hashvalue, filename, dir, filesize,
|
||||
owner, uploadcategorycode, public, permanent) VALUES (?,?,?,?,?,?,?,?)';
|
||||
my @pars= (
|
||||
$self->{files}->{$filename}->{hash},
|
||||
$filename,
|
||||
$self->{category},
|
||||
$size,
|
||||
$self->{uid},
|
||||
$self->{category},
|
||||
$self->{public},
|
||||
$self->{temporary}? 0: 1,
|
||||
);
|
||||
$dbh->do( $sql, undef, @pars );
|
||||
my $i = $dbh->last_insert_id(undef, undef, 'uploaded_files', undef);
|
||||
$self->{files}->{$filename}->{id} = $i if $i;
|
||||
my $rec = Koha::UploadedFile->new({
|
||||
hashvalue => $self->{files}->{$filename}->{hash},
|
||||
filename => $filename,
|
||||
dir => $self->{category},
|
||||
filesize => $size,
|
||||
owner => $self->{uid},
|
||||
uploadcategorycode => $self->{category},
|
||||
public => $self->{public},
|
||||
permanent => $self->{temporary}? 0: 1,
|
||||
})->store;
|
||||
$self->{files}->{$filename}->{id} = $rec->id if $rec;
|
||||
}
|
||||
|
||||
sub _lookup {
|
||||
|
|
|
|||
Loading…
Reference in New Issue