From 900c189938e3367850a5f1465c4a857f2ee9a32e Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Fri, 27 Jul 2012 21:33:15 -0400 Subject: [PATCH] Bug 8437: variable scoping for tools/export.pl Variable scoping problems prevented database export from working under Plack. This patch fixes that. Signed-off-by: Dobrica Pavlinusic --- tools/export.pl | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index 95b8185..d863547 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -128,8 +128,6 @@ if ( C4::Context->preference("IndependantBranches") && $branch = C4::Context->userenv->{'branch'}; } -my $backupdir = C4::Context->config('backupdir'); - if ($op eq "export") { my $charset = 'utf-8'; my $mimetype = 'application/octet-stream'; @@ -277,6 +275,7 @@ if ($op eq "export") { } } elsif ( $record_type eq 'db' ) { + my $backupdir = C4::Context->config('backupdir'); my $successful_export; if ( $flags->{superlibrarian} && C4::Context->config('backup_db_via_tools') ) { $successful_export = download_backup( { directory => "$backupdir", extension => 'sql', filename => "$filename" } ) @@ -289,6 +288,7 @@ if ($op eq "export") { exit; } elsif ( $record_type eq 'conf' ) { + my $backupdir = C4::Context->config('backupdir'); my $successful_export; if ( $flags->{superlibrarian} && C4::Context->config('backup_conf_via_tools') ) { $successful_export = download_backup( { directory => "$backupdir", extension => 'tar', filename => "$filename" } ) @@ -384,6 +384,7 @@ if ($op eq "export") { else { + my $backupdir = C4::Context->config('backupdir'); my $itemtypes = GetItemTypes; my @itemtypesloop; foreach my $thisitemtype (sort keys %$itemtypes) { @@ -445,6 +446,8 @@ sub getbackupfilelist { my $extension = $args->{extension}; my @files; + my $backupdir = C4::Context->config('backupdir'); + if ( opendir(my $dir, $directory) ) { while (my $file = readdir($dir)) { next unless ( $file =~ m/\.$extension(\.(gz|bz2|xz))?/ ); -- 1.7.2.5