Bugzilla – Attachment 77173 Details for
Bug 19633
Use alphanumeric error codes in upload
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19633: (QA follow-up) Really remove these ugly numbers
Bug-19633-QA-follow-up-Really-remove-these-ugly-nu.patch (text/plain), 4.96 KB, created by
Jonathan Druart
on 2018-07-20 16:39:00 UTC
(
hide
)
Description:
Bug 19633: (QA follow-up) Really remove these ugly numbers
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-07-20 16:39:00 UTC
Size:
4.96 KB
patch
obsolete
>From 9ee8bd9a1eed09b89c092ed402f7b8a052b319de Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 6 Jun 2018 15:41:09 +0200 >Subject: [PATCH] Bug 19633: (QA follow-up) Really remove these ugly numbers > >See BZ comment5. We now remove the numbers also from the constant names. > >Test plan: >Read the changes. >Git grep "ERRCODE_" >Run t/db_dependent/Upload.t (Note: You may see one failure here; it is fixed >on bug 20727. So depends on who reaches master first.) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Uploader.pm | 16 ++++++++-------- > t/db_dependent/Upload.t | 2 +- > tools/upload.pl | 12 ++++++------ > 3 files changed, 15 insertions(+), 15 deletions(-) > >diff --git a/Koha/Uploader.pm b/Koha/Uploader.pm >index dd60d51934..a4baa6a30b 100644 >--- a/Koha/Uploader.pm >+++ b/Koha/Uploader.pm >@@ -60,10 +60,10 @@ Koha::Uploader - Facilitate file uploads (temporary and permanent) > > use constant KOHA_UPLOAD => 'koha_upload'; > use constant BYTES_DIGEST => 2048; >-use constant ERRCODE_1 => 'UPLERR_ALREADY_EXISTS'; >-use constant ERRCODE_2 => 'UPLERR_CANNOT_WRITE'; >-use constant ERRCODE_3 => 'UPLERR_NO_ROOT_DIR'; >-use constant ERRCODE_4 => 'UPLERR_NO_TEMP_DIR'; >+use constant ERR_EXISTS => 'UPLERR_ALREADY_EXISTS'; >+use constant ERR_PERMS => 'UPLERR_CANNOT_WRITE'; >+use constant ERR_ROOT => 'UPLERR_NO_ROOT_DIR'; >+use constant ERR_TEMP => 'UPLERR_NO_TEMP_DIR'; > > use Modern::Perl; > use CGI; # no utf8 flag, since it may interfere with binary uploads >@@ -224,9 +224,9 @@ sub _create_file { > $self->{files}->{$filename}->{errcode} ) { > #skip > } elsif( !$self->{temporary} && !$self->{rootdir} ) { >- $self->{files}->{$filename}->{errcode} = ERRCODE_3; #no rootdir >+ $self->{files}->{$filename}->{errcode} = ERR_ROOT; #no rootdir > } elsif( $self->{temporary} && !$self->{tmpdir} ) { >- $self->{files}->{$filename}->{errcode} = ERRCODE_4; #no tempdir >+ $self->{files}->{$filename}->{errcode} = ERR_TEMP; #no tempdir > } else { > my $dir = $self->_dir; > my $hashval = $self->{files}->{$filename}->{hash}; >@@ -239,7 +239,7 @@ sub _create_file { > hashvalue => $hashval, > uploadcategorycode => $self->{category}, > })->count ) { >- $self->{files}->{$filename}->{errcode} = ERRCODE_1; #already exists >+ $self->{files}->{$filename}->{errcode} = ERR_EXISTS; > return; > } > >@@ -248,7 +248,7 @@ sub _create_file { > $fh->binmode; > $self->{files}->{$filename}->{fh}= $fh; > } else { >- $self->{files}->{$filename}->{errcode} = ERRCODE_2; #not writable >+ $self->{files}->{$filename}->{errcode} = ERR_PERMS; > } > } > return $fh; >diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t >index 8b4f0ba7c4..802dc58da0 100644 >--- a/t/db_dependent/Upload.t >+++ b/t/db_dependent/Upload.t >@@ -145,7 +145,7 @@ subtest 'Add same file in same category' => sub { > is( $upl->count, 0, 'Upload 4 failed as expected' ); > is( $upl->result, undef, 'Result is undefined' ); > my $e = $upl->err; >- is( $e->{file2}->{code}, Koha::Uploader::ERRCODE_1, "Errcode [already exists] reported" ); >+ is( $e->{file2}->{code}, Koha::Uploader::ERR_EXISTS, "Already exists error reported" ); > }; > > subtest 'Test delete via UploadedFile as well as UploadedFiles' => sub { >diff --git a/tools/upload.pl b/tools/upload.pl >index 20820b8c47..afb7c516f9 100755 >--- a/tools/upload.pl >+++ b/tools/upload.pl >@@ -25,9 +25,9 @@ use C4::Auth; > use C4::Output; > use Koha::UploadedFiles; > >-use constant ERRCODE_5 => 'UPLERR_FILE_NOT_READ'; >-use constant ALRCODE_6 => 'UPL_FILE_DELETED'; # alert, no error >-use constant ERRCODE_7 => 'UPLERR_FILE_NOT_DELETED'; >+use constant ERR_READING => 'UPLERR_FILE_NOT_READ'; >+use constant ALERT_DELETED => 'UPL_FILE_DELETED'; # alert, no error >+use constant ERR_NOT_DELETED => 'UPLERR_FILE_NOT_DELETED'; > > my $input = CGI::->new; > my $op = $input->param('op') // 'new'; >@@ -91,9 +91,9 @@ if ( $op eq 'new' ) { > my $delete = $rec ? $rec->delete : undef; > #TODO Improve error handling > my $msg = $delete >- ? JSON::to_json({ $fn => { code => ALRCODE_6 }}) >+ ? JSON::to_json({ $fn => { code => ALERT_DELETED }}) > : $id >- ? JSON::to_json({ $fn || $id, { code => ERRCODE_7 }}) >+ ? JSON::to_json({ $fn || $id, { code => ERR_NOT_DELETED }}) > : ''; > $template->param( > mode => 'deleted', >@@ -108,7 +108,7 @@ if ( $op eq 'new' ) { > if ( !$rec || !$fh ) { > $template->param( > mode => 'new', >- msg => JSON::to_json({ $id => { code => ERRCODE_5 }}), >+ msg => JSON::to_json({ $id => { code => ERR_READING }}), > ); > output_html_with_http_headers $input, $cookie, $template->output; > } else { >-- >2.11.0
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 19633
:
72084
|
72919
|
74722
|
75856
|
77172
| 77173