@@ -, +, @@ Koha::UploadedFile->temporary_directory --- 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(-) --- a/C4/Auth.pm +++ a/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" } }; } --- a/C4/InstallAuth.pm +++ a/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; --- a/Koha/Edifact/Transport.pm +++ a/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' ), }; --- a/misc/cronjobs/fines.pl +++ a/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!"; --- a/t/db_dependent/Plugins.t +++ a/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; --- a/t/db_dependent/Sitemapper.t +++ a/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/], --- a/t/db_dependent/Templates.t +++ a/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({ --