From 3f5a62dc7395d142684e0a7bdf6ce904b64e76cf 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 Content-Type: text/plain; charset="UTF-8" Variable scoping problems prevented database export from working under Plack. This patch fixes that. --- tools/export.pl | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index d3ad16f..e20b8e1 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -59,8 +59,6 @@ my ($template, $loggedinuser, $cookie, $flags) $branch = C4::Context->userenv->{'branch'}; } -my $backupdir = C4::Context->config('backupdir'); - if ($op eq "export") { my $charset = 'utf-8'; my $mimetype = 'application/octet-stream'; @@ -175,6 +173,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" } ) @@ -187,6 +186,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" } ) @@ -269,6 +269,7 @@ if ($op eq "export") { else { + my $backupdir = C4::Context->config('backupdir'); my $itemtypes = GetItemTypes; my @itemtypesloop; foreach my $thisitemtype (sort keys %$itemtypes) { @@ -328,6 +329,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