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 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>
This commit is contained in:
parent
bf86fdd92d
commit
c2b0c92800
7 changed files with 18 additions and 13 deletions
|
@ -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::DateUtils qw(dt_from_string);
|
||||
|
@ -1740,7 +1740,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" } };
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -237,7 +239,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;
|
||||
|
|
|
@ -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' ),
|
||||
};
|
||||
|
||||
|
|
|
@ -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!";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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/],
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue