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
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
use strict;
use warnings;
use Digest::MD5 qw(md5_base64);
-use File::Spec;
use JSON qw/encode_json/;
use URI::Escape;
use CGI::Session;
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::DateUtils qw(dt_from_string);
}
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" } };
}
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);
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;
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 );
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' ),
};
use Koha::Calendar;
use Koha::DateUtils;
+use Koha::UploadedFile;
use C4::Log;
my $help;
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!";
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;
use Test::MockModule;
use C4::Context;
+use Koha::UploadedFile;
+
use t::lib::Mocks;
BEGIN {
# 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;
use Koha::Schema;
use Carp qw/croak carp/;
+use Koha::UploadedFile;
+
BEGIN {
use_ok('Koha::Sitemapper');
use_ok('Koha::Sitemapper::Writer');
_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/],
use Test::Deep;
use Test::MockModule;
use Test::Warn;
-use File::Spec;
use File::Temp qw/tempfile/;
use t::lib::Mocks;
# 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({