@@ -, +, @@ --- C4/Auth.pm | 2 +- C4/Context.pm | 12 ++++++++++++ C4/InstallAuth.pm | 2 +- Koha/Edifact/Transport.pm | 2 +- Koha/UploadedFile.pm | 11 ----------- Koha/Uploader.pm | 2 +- about.pl | 2 +- misc/cronjobs/fines.pl | 2 +- t/db_dependent/Plugins.t | 2 +- t/db_dependent/Sitemapper.t | 2 +- t/db_dependent/Templates.t | 4 ++-- t/db_dependent/Upload.t | 2 +- 12 files changed, 23 insertions(+), 22 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -1740,7 +1740,7 @@ sub _get_session_params { } else { # catch all defaults to tmp should work on all systems - my $dir = Koha::UploadedFile->temporary_directory; + my $dir = C4::Context::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/Context.pm +++ a/C4/Context.pm @@ -1076,6 +1076,18 @@ sub only_my_library { && C4::Context->userenv->{branch}; } +=head3 temporary_directory + +Returns root directory for temporary storage + +=cut + +sub temporary_directory { + my ( $class ) = @_; + return C4::Context->config('tmp_path') || File::Spec->tmpdir; +} + + 1; __END__ --- a/C4/InstallAuth.pm +++ a/C4/InstallAuth.pm @@ -239,7 +239,7 @@ sub checkauth { my $dbh = C4::Context->dbh(); my $template_name; $template_name = "installer/auth.tt"; - my $sessdir = File::Spec->catdir( Koha::UploadedFile->temporary_directory, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth + my $sessdir = File::Spec->catdir( C4::Context::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 @@ -40,7 +40,7 @@ sub new { my $self = { account => $acct, schema => $schema, - working_dir => Koha::UploadedFile->temporary_directory, #temporary work directory + working_dir => C4::Context::temporary_directory, #temporary work directory transfer_date => DateTime->now( time_zone => 'local' ), }; --- a/Koha/UploadedFile.pm +++ a/Koha/UploadedFile.pm @@ -160,17 +160,6 @@ sub permanent_directory { return C4::Context->config('upload_path'); } -=head3 tmp_directory - -Returns root directory for temporary storage - -=cut - -sub temporary_directory { - my ( $class ) = @_; - return C4::Context->config('tmp_path') || File::Spec->tmpdir; -} - =head3 _type Returns name of corresponding DBIC resultset --- a/Koha/Uploader.pm +++ a/Koha/Uploader.pm @@ -189,7 +189,7 @@ sub _init { my ( $self, $params ) = @_; $self->{rootdir} = Koha::UploadedFile->permanent_directory; - $self->{tmpdir} = Koha::UploadedFile->temporary_directory; + $self->{tmpdir} = C4::Context::temporary_directory; $params->{tmp} = $params->{temp} if !exists $params->{tmp}; $self->{temporary} = $params->{tmp}? 1: 0; #default false --- a/about.pl +++ a/about.pl @@ -263,7 +263,7 @@ if ( ! defined C4::Context->config('upload_path') ) { } if ( ! C4::Context->config('tmp_path') ) { - my $temporary_directory = Koha::UploadedFile->temporary_directory; + my $temporary_directory = C4::Context::temporary_directory; push @xml_config_warnings, { error => 'tmp_path_missing', effective_tmp_dir => $temporary_directory, --- a/misc/cronjobs/fines.pl +++ a/misc/cronjobs/fines.pl @@ -184,7 +184,7 @@ sub set_holiday { sub get_filename { my $directory = shift; if ( !$directory ) { - $directory = Koha::UploadedFile->temporary_directory; + $directory = C4::Context::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 @@ -63,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', [ Koha::UploadedFile->temporary_directory ] ); +t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::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 @@ -64,7 +64,7 @@ $db->mock( _new_schema => sub { return Schema(); } ); -my $dir = Koha::UploadedFile->temporary_directory; +my $dir = C4::Context::temporary_directory; my $data = [ [qw/ 1 2013-11-15 2013-11-15/], --- a/t/db_dependent/Templates.t +++ a/t/db_dependent/Templates.t @@ -126,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', [ Koha::UploadedFile->temporary_directory ] ); + t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::temporary_directory ] ); t::lib::Mocks::mock_preference( 'OPACBaseURL', 'without any doubt' ); - my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => Koha::UploadedFile->temporary_directory ); + my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => C4::Context::temporary_directory ); print $fh q|I am a [% quality %] template [% OPACBaseURL %]|; close $fh; my ( $template, $login, $cookie ) = C4::Auth::get_template_and_user({ --- a/t/db_dependent/Upload.t +++ a/t/db_dependent/Upload.t @@ -74,7 +74,7 @@ subtest 'permanent_directory and temporary_directory' => sub { # Check mocked directories is( Koha::UploadedFile->permanent_directory, $tempdir, 'Check permanent directory' ); - is( Koha::UploadedFile->temporary_directory, $tempdir, + is( C4::Context::temporary_directory, $tempdir, 'Check temporary directory' ); }; --