Bugzilla – Attachment 75626 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: Move temporary_directory() to C4::Context
Bug-20727-Move-temporarydirectory-to-C4Context.patch (text/plain), 7.54 KB, created by
Kyle M Hall (khall)
on 2018-05-29 12:04:17 UTC
(
hide
)
Description:
Bug 20727: Move temporary_directory() to C4::Context
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-05-29 12:04:17 UTC
Size:
7.54 KB
patch
obsolete
>From 62d61f697bd1a4a7f90c2437af31c38b60c2ef71 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Tue, 29 May 2018 08:03:55 -0400 >Subject: [PATCH] Bug 20727: Move temporary_directory() to C4::Context > >--- > 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(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 17e725120e..6c8f2db38d 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1745,7 +1745,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" } }; > } >diff --git a/C4/Context.pm b/C4/Context.pm >index 7ce91b6b35..247b7a46fa 100644 >--- a/C4/Context.pm >+++ b/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__ >diff --git a/C4/InstallAuth.pm b/C4/InstallAuth.pm >index 0e72290cf2..c03cb970a6 100644 >--- a/C4/InstallAuth.pm >+++ b/C4/InstallAuth.pm >@@ -240,7 +240,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; >diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm >index 0fa1d67244..c14df3a5be 100644 >--- a/Koha/Edifact/Transport.pm >+++ b/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' ), > }; > >diff --git a/Koha/UploadedFile.pm b/Koha/UploadedFile.pm >index a8eb8a3df3..cee92653d8 100644 >--- a/Koha/UploadedFile.pm >+++ b/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 >diff --git a/Koha/Uploader.pm b/Koha/Uploader.pm >index 8e6a2aa36f..e1b34c9e0e 100644 >--- a/Koha/Uploader.pm >+++ b/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 >diff --git a/about.pl b/about.pl >index 70900dd2c4..6151d18e62 100755 >--- a/about.pl >+++ b/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, >diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl >index fec343e9cd..9fa7b94f98 100755 >--- a/misc/cronjobs/fines.pl >+++ b/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!"; >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index 3f7601ea64..24150593ba 100755 >--- a/t/db_dependent/Plugins.t >+++ b/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; >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index 3e47d6f2f3..91a4933d38 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/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/], >diff --git a/t/db_dependent/Templates.t b/t/db_dependent/Templates.t >index f45dcffebc..2efce26c29 100755 >--- a/t/db_dependent/Templates.t >+++ b/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({ >diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t >index 3637244133..ccb879a7d6 100644 >--- a/t/db_dependent/Upload.t >+++ b/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' ); > }; > >-- >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