summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Config.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-08-10 21:41:53 +0200
committerdklawren <dklawren@users.noreply.github.com>2018-08-10 21:41:53 +0200
commitea5beeacb185309572836cc60989f95ea4705f9d (patch)
tree1f8f44b5d1dba73fb05214ba1e539c0918d42bb9 /Bugzilla/Config.pm
parent53e1adcc77b3e68c1d8659d418aa5639d9917e42 (diff)
downloadbugzilla-ea5beeacb185309572836cc60989f95ea4705f9d.tar.gz
bugzilla-ea5beeacb185309572836cc60989f95ea4705f9d.tar.xz
Bug 1482475 - Add extensive testing framework
Diffstat (limited to 'Bugzilla/Config.pm')
-rw-r--r--Bugzilla/Config.pm37
1 files changed, 19 insertions, 18 deletions
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index d050ff9e0..85779fa6b 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -251,28 +251,11 @@ sub write_params {
my ($param_data) = @_;
$param_data ||= Bugzilla->params;
- my $datadir = bz_locations()->{'datadir'};
- my $param_file = "$datadir/params";
-
local $Data::Dumper::Sortkeys = 1;
- my ($fh, $tmpname) = File::Temp::tempfile('params.XXXXX',
- DIR => $datadir );
-
my %params = %$param_data;
$params{urlbase} = Bugzilla->localconfig->{urlbase};
- print $fh (Data::Dumper->Dump([\%params], ['*param']))
- || die "Can't write param file: $!";
-
- close $fh;
-
- rename $tmpname, $param_file
- or die "Can't rename $tmpname to $param_file: $!";
-
- # It's not common to edit parameters and loading
- # Bugzilla::Install::Filesystem is slow.
- require Bugzilla::Install::Filesystem;
- Bugzilla::Install::Filesystem::fix_file_permissions($param_file);
+ __PACKAGE__->_write_file( Data::Dumper->Dump([\%params], ['*param']) );
# And now we have to reset the params cache so that Bugzilla will re-read
# them.
@@ -311,6 +294,24 @@ sub read_param_file {
return \%params;
}
+sub _write_file {
+ my ($class, $str) = @_;
+ my $datadir = bz_locations()->{'datadir'};
+ my $param_file = "$datadir/params";
+ my ($fh, $tmpname) = File::Temp::tempfile('params.XXXXX',
+ DIR => $datadir );
+ print $fh $str || die "Can't write param file: $!";
+ close $fh || die "Can't close param file: $!";
+
+ rename $tmpname, $param_file
+ or die "Can't rename $tmpname to $param_file: $!";
+
+ # It's not common to edit parameters and loading
+ # Bugzilla::Install::Filesystem is slow.
+ require Bugzilla::Install::Filesystem;
+ Bugzilla::Install::Filesystem::fix_file_permissions($param_file);
+}
+
1;
__END__