Bugzilla – Attachment 75200 Details for
Bug 20727
Replace usage of File::Spec->tmpdir with C4::Context->temporary_directory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20727: Replace usage of File::Spec->tmpdir with Koha::UploadedFile->temporary_directory
Bug-20727-Replace-usage-of-FileSpec-tmpdir-with-Ko.patch (text/plain), 7.08 KB, created by
Kyle M Hall (khall)
on 2018-05-09 10:48:25 UTC
(
hide
)
Description:
Bug 20727: Replace usage of File::Spec->tmpdir with Koha::UploadedFile->temporary_directory
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-05-09 10:48:25 UTC
Size:
7.08 KB
patch
obsolete
>From 37c2121b731a6a87c841e26cf897b91f638c2946 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Wed, 9 May 2018 06:44:41 -0400 >Subject: [PATCH] Bug 20727: Replace usage of File::Spec->tmpdir with > Koha::UploadedFile->temporary_directory > >As explained in bug 20428 use tmpdir can cause issues and it just makes sense to standardize our temp directory in a universal way. > >Test Plan: >1) Apply this patch >2) Verify you can still log in and use Koha >3) Verify the web installer still works >4) Verify EDI module can still download files via FTP >5) Verify fines.pl still runs with -o option >6) prove t/db_dependent/Plugins.t >7) prove t/db_dependent/Sitemapper.t >8) prove t/db_dependent/Templates.t >--- > C4/Auth.pm | 4 ++-- > C4/InstallAuth.pm | 6 ++++-- > Koha/Edifact/Transport.pm | 4 ++-- > misc/cronjobs/fines.pl | 3 ++- > t/db_dependent/Plugins.t | 5 +++-- > t/db_dependent/Sitemapper.t | 4 +++- > t/db_dependent/Templates.t | 5 ++--- > 7 files changed, 18 insertions(+), 13 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 7442b1dd78..17e725120e 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -20,7 +20,6 @@ package C4::Auth; > use strict; > use warnings; > use Digest::MD5 qw(md5_base64); >-use File::Spec; > use JSON qw/encode_json/; > use URI::Escape; > use CGI::Session; >@@ -31,6 +30,7 @@ use C4::Templates; # to get the template > use C4::Languages; > use C4::Search::History; > use Koha; >+use Koha::UploadedFile; > use Koha::Caches; > use Koha::AuthUtils qw(get_script_name hash_password); > use Koha::Library::Groups; >@@ -1745,7 +1745,7 @@ sub _get_session_params { > } > else { > # catch all defaults to tmp should work on all systems >- my $dir = File::Spec->tmpdir; >+ my $dir = Koha::UploadedFile->temporary_directory; > my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is > return { dsn => "driver:File;serializer:yaml;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } }; > } >diff --git a/C4/InstallAuth.pm b/C4/InstallAuth.pm >index 9d285bda1b..0e72290cf2 100644 >--- a/C4/InstallAuth.pm >+++ b/C4/InstallAuth.pm >@@ -20,14 +20,16 @@ package C4::InstallAuth; > use strict; > #use warnings; FIXME - Bug 2505 > use Digest::MD5 qw(md5_base64); >+use CGI::Session; > use File::Spec; > > require Exporter; >+ > use C4::Context; > use C4::Output; > use C4::Templates; > use C4::Koha; >-use CGI::Session; >+use Koha::UploadedFile; > > use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -238,7 +240,7 @@ sub checkauth { > my $dbh = C4::Context->dbh(); > my $template_name; > $template_name = "installer/auth.tt"; >- my $sessdir = File::Spec->catdir( File::Spec->tmpdir, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth >+ my $sessdir = File::Spec->catdir( Koha::UploadedFile->temporary_directory, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth > > # state variables > my $loggedin = 0; >diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm >index caf2f5def3..0fa1d67244 100644 >--- a/Koha/Edifact/Transport.pm >+++ b/Koha/Edifact/Transport.pm >@@ -28,7 +28,7 @@ use Net::SFTP::Foreign; > use File::Slurp; > use File::Copy; > use File::Basename qw( fileparse ); >-use File::Spec; >+use Koha::UploadedFile; > use Koha::Database; > use Encode qw( from_to ); > >@@ -40,7 +40,7 @@ sub new { > my $self = { > account => $acct, > schema => $schema, >- working_dir => File::Spec->tmpdir(), #temporary work directory >+ working_dir => Koha::UploadedFile->temporary_directory, #temporary work directory > transfer_date => DateTime->now( time_zone => 'local' ), > }; > >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index 87c732e27a..fec343e9cd 100755 >--- a/misc/cronjobs/fines.pl >+++ b/misc/cronjobs/fines.pl >@@ -38,6 +38,7 @@ use File::Spec; > > use Koha::Calendar; > use Koha::DateUtils; >+use Koha::UploadedFile; > use C4::Log; > > my $help; >@@ -183,7 +184,7 @@ sub set_holiday { > sub get_filename { > my $directory = shift; > if ( !$directory ) { >- $directory = File::Spec->tmpdir(); >+ $directory = Koha::UploadedFile->temporary_directory; > } > if ( !-d $directory ) { > carp "Could not write to $directory ... does not exist!"; >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index 1e76ed245f..2cf9d31883 100755 >--- a/t/db_dependent/Plugins.t >+++ b/t/db_dependent/Plugins.t >@@ -5,7 +5,6 @@ use Modern::Perl; > use Test::More tests => 35; > use CGI; > use File::Basename; >-use File::Spec; > use File::Temp qw( tempdir tempfile ); > use FindBin qw($Bin); > use Archive::Extract; >@@ -13,6 +12,8 @@ use Module::Load::Conditional qw(can_load); > use Test::MockModule; > > use C4::Context; >+use Koha::UploadedFile; >+ > use t::lib::Mocks; > > BEGIN { >@@ -62,7 +63,7 @@ is( $plugin->get_plugin_http_path(), '/plugin/Koha/Plugin/Test', 'Test $plugin-> > # test absolute path change in get_template with Koha::Plugin::Test > # using the mock set before > # we also add tmpdir as an approved template dir >-t::lib::Mocks::mock_config( 'pluginsdir', [ File::Spec->tmpdir ] ); >+t::lib::Mocks::mock_config( 'pluginsdir', [ Koha::UploadedFile->temporary_directory ] ); > my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1 ); > print $fh 'I am [% filename %]'; > close $fh; >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index 9f9945d7e9..3e47d6f2f3 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/t/db_dependent/Sitemapper.t >@@ -26,6 +26,8 @@ use Test::More tests => 16; > use Koha::Schema; > use Carp qw/croak carp/; > >+use Koha::UploadedFile; >+ > BEGIN { > use_ok('Koha::Sitemapper'); > use_ok('Koha::Sitemapper::Writer'); >@@ -62,7 +64,7 @@ $db->mock( > _new_schema => sub { return Schema(); } > ); > >-my $dir = File::Spec->tmpdir(); >+my $dir = Koha::UploadedFile->temporary_directory; > > my $data = [ > [qw/ 1 2013-11-15 2013-11-15/], >diff --git a/t/db_dependent/Templates.t b/t/db_dependent/Templates.t >index 73a42a6494..f45dcffebc 100755 >--- a/t/db_dependent/Templates.t >+++ b/t/db_dependent/Templates.t >@@ -23,7 +23,6 @@ use Test::More tests => 8; > use Test::Deep; > use Test::MockModule; > use Test::Warn; >-use File::Spec; > use File::Temp qw/tempfile/; > > use t::lib::Mocks; >@@ -127,9 +126,9 @@ subtest "Absolute path change in _get_template_file" => sub { > # We create a simple template in /tmp. > # We simulate an anonymous OPAC session; the OPACBaseURL template variable > # should be filled by get_template_and_user. >- t::lib::Mocks::mock_config( 'pluginsdir', [ File::Spec->tmpdir ] ); >+ t::lib::Mocks::mock_config( 'pluginsdir', [ Koha::UploadedFile->temporary_directory ] ); > t::lib::Mocks::mock_preference( 'OPACBaseURL', 'without any doubt' ); >- my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1 ); >+ my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => Koha::UploadedFile->temporary_directory ); > print $fh q|I am a [% quality %] template [% OPACBaseURL %]|; > close $fh; > my ( $template, $login, $cookie ) = C4::Auth::get_template_and_user({ >-- >2.15.1 (Apple Git-101)
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 20727
:
75200
|
75626
|
75667
|
75668
|
75669
|
75670
|
75833
|
75834
|
75835
|
75923
|
75924
|
75925
|
75926
|
75927
|
75928