diff options
author | Dylan William Hardison <dylan@hardison.net> | 2015-10-31 02:03:58 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2015-10-31 02:06:57 +0100 |
commit | 5852295860d51040f69bbaf957cc8ed6bfd7358b (patch) | |
tree | a0781afa608c45912a97c1b2ac3b75e0d8659f2b /Bugzilla | |
parent | f03cb21e297f73fcfca9740ff8e2c525a745d7ad (diff) | |
download | bugzilla-5852295860d51040f69bbaf957cc8ed6bfd7358b.tar.gz bugzilla-5852295860d51040f69bbaf957cc8ed6bfd7358b.tar.xz |
Bug 1218457 - Allow localconfig to override (force) certain data/params values
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/DB.pm | 16 | ||||
-rw-r--r-- | Bugzilla/Install/Localconfig.pm | 12 | ||||
-rw-r--r-- | Bugzilla/Memcached.pm | 9 | ||||
-rw-r--r-- | Bugzilla/Util.pm | 2 |
4 files changed, 25 insertions, 14 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index f201124a8..cc2826f55 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -118,19 +118,19 @@ sub quote { sub connect_shadow { my $params = Bugzilla->params; - die "Tried to connect to non-existent shadowdb" - unless $params->{'shadowdb'}; + die "Tried to connect to non-existent shadowdb" + unless Bugzilla->get_param_with_override('shadowdb'); # Instead of just passing in a new hashref, we locally modify the # values of "localconfig", because some drivers access it while # connecting. - my %connect_params = %{ Bugzilla->localconfig }; - $connect_params{db_host} = $params->{'shadowdbhost'}; - $connect_params{db_name} = $params->{'shadowdb'}; - $connect_params{db_port} = $params->{'shadowdbport'}; - $connect_params{db_sock} = $params->{'shadowdbsock'}; + my $connect_params = dclone(Bugzilla->localconfig); + $connect_params->{db_host} = Bugzilla->get_param_with_override('shadowdbhost'); + $connect_params->{db_name} = Bugzilla->get_param_with_override('shadowdb'); + $connect_params->{db_port} = Bugzilla->get_param_with_override('shadowport'); + $connect_params->{db_sock} = Bugzilla->get_param_with_override('shadowsock'); - return _connect(\%connect_params); + return _connect($connect_params); } sub connect_main { diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm index 1544e6fac..dbc0624d3 100644 --- a/Bugzilla/Install/Localconfig.pm +++ b/Bugzilla/Install/Localconfig.pm @@ -114,6 +114,18 @@ use constant LOCALCONFIG_VARS => ( # is larger than anybody would ever be able to brute-force. default => sub { generate_random_password(64) }, }, + { + name => 'param_override', + default => { + inbound_proxies => undef, + memcached_servers => undef, + memcached_namespace => undef, + shadowdb => undef, + shadowdbhost => undef, + shadowdbport => undef, + shadowdbsock => undef, + }, + }, ); sub read_localconfig { diff --git a/Bugzilla/Memcached.pm b/Bugzilla/Memcached.pm index fdafa0014..1339a119c 100644 --- a/Bugzilla/Memcached.pm +++ b/Bugzilla/Memcached.pm @@ -28,14 +28,13 @@ sub _new { # always return an object to simplify calling code when memcached is # disabled. - if (Bugzilla->feature('memcached') - && Bugzilla->params->{memcached_servers}) - { + my $servers = Bugzilla->get_param_with_override('memcached_servers'); + if (Bugzilla->feature('memcached') && $servers) { require Cache::Memcached; - $self->{namespace} = Bugzilla->params->{memcached_namespace} || ''; + $self->{namespace} = Bugzilla->get_param_with_override('memcached_namespace'); $self->{memcached} = Cache::Memcached->new({ - servers => [ split(/[, ]+/, Bugzilla->params->{memcached_servers}) ], + servers => [ split(/[, ]+/, $servers) ], namespace => $self->{namespace}, }); } diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index f793ed727..19444082f 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -308,7 +308,7 @@ sub correct_urlbase { # Returns the real remote address of the client, sub remote_ip { my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1'; - my @proxies = split(/[\s,]+/, Bugzilla->params->{inbound_proxies}); + my @proxies = split(/[\s,]+/, Bugzilla->get_param_with_override('inbound_proxies')); my @x_forwarded_for = split(/[\s,]+/, $ENV{HTTP_X_FORWARDED_FOR} // ''); return $remote_ip unless @x_forwarded_for; |