Bugzilla – Attachment 59343 Details for
Bug 17501
Koha Objects for uploaded files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17501: Use Koha::Object in Koha::Upload::_register
Bug-17501-Use-KohaObject-in-KohaUploadregister.patch (text/plain), 2.11 KB, created by
Jonathan Druart
on 2017-01-20 11:40:22 UTC
(
hide
)
Description:
Bug 17501: Use Koha::Object in Koha::Upload::_register
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-20 11:40:22 UTC
Size:
2.11 KB
patch
obsolete
>From 34775315ef05ae578ee50dcd0810e84fed14a3c5 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Sun, 20 Nov 2016 16:10:33 +0100 >Subject: [PATCH] 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> >--- > Koha/Upload.pm | 28 ++++++++++++---------------- > 1 file changed, 12 insertions(+), 16 deletions(-) > >diff --git a/Koha/Upload.pm b/Koha/Upload.pm >index ceff56a..2e4aa04 100644 >--- a/Koha/Upload.pm >+++ b/Koha/Upload.pm >@@ -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 { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17501
:
57751
|
57752
|
57753
|
57754
|
57755
|
57756
|
57757
|
57758
|
57759
|
58613
|
58614
|
58615
|
58616
|
58617
|
58618
|
58619
|
58620
|
58621
|
58809
|
59342
| 59343 |
59344
|
59345
|
59346
|
59347
|
59348
|
59349
|
59350
|
59351