From f52512d1be68f881e5d19809f3f07aa5e28f40be Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 29 May 2015 08:57:31 +0200 Subject: [PATCH] Bug 14295: Add creation time, size and owner for uploaded files Content-Type: text/plain; charset=utf-8 When inserting a new record in uploaded_files, we want to fill the new columns correctly. Test plan: Upload a file via the upload plugin. Verify that filesize, owner and creation time are correct in the database record. Run the unit test UploadedFiles.t. --- C4/UploadedFiles.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/C4/UploadedFiles.pm b/C4/UploadedFiles.pm index bf040bd..d8a5be4 100644 --- a/C4/UploadedFiles.pm +++ b/C4/UploadedFiles.pm @@ -175,11 +175,14 @@ sub UploadFile { my $dbh = C4::Context->dbh; my $query = qq{ - INSERT INTO uploaded_files (id, filename, dir) - VALUES (?,?, ?); + INSERT INTO uploaded_files + (id, filename, dir, filesize, owner) + VALUES (?,?, ?, ?, ?); }; my $sth = $dbh->prepare($query); - if($sth->execute($id, $filename, $dir)) { + my $ue = C4::Context->userenv; + my $owner = $ue? $ue->{number}: undef; + if( $sth->execute($id, $filename, $dir, length($data), $owner ) ) { return $id; } -- 1.7.10.4