# And now we have to reset the params cache so that Bugzilla will re-read
# them.
+ Bugzilla->memcached->clear_params();
delete Bugzilla->request_cache->{params};
}
sub read_param_file {
+ my $cached_params = Bugzilla->memcached->get_params();
+ return $cached_params if $cached_params;
my %params;
my $datadir = bz_locations()->{'datadir'};
if (-e "$datadir/params") {
die "The $datadir/params file does not exist."
. ' You probably need to run checksetup.pl.',
}
+ Bugzilla->memcached->set_params(\%params);
return \%params;
}
return scalar getgrgid($EGID);
}
-sub _migrate_param {
- my ( $name, $fallback_value ) = @_;
-
- return sub {
- if ( Bugzilla->can('params') ) {
- return Bugzilla->params->{$name} // $fallback_value;
- }
- else {
- return $fallback_value;
- }
- };
-}
-
use constant LOCALCONFIG_VARS => (
{
name => 'create_htaccess',
},
{
name => 'memcached_servers',
- default => _migrate_param( "memcached_servers", "" ),
+ default => '',
},
{
name => 'memcached_namespace',
- default => _migrate_param( "memcached_namespace", "bugzilla:" ),
+ default => "bugzilla:",
},
{
name => 'urlbase',
- default => _migrate_param( "urlbase", "" ),
+ default => '',
},
{
name => 'canonical_urlbase',
},
{
name => 'attachment_base',
- default => _migrate_param( "attachment_base", '' ),
+ default => '',
},
{
name => 'ses_username',
},
{
name => 'inbound_proxies',
- default => _migrate_param( 'inbound_proxies', '' ),
+ default => '',
},
{
name => 'shadowdb_user',
}
}
+sub set_params {
+ my ($self, $params) = @_;
+ return unless $self->{memcached};
+
+ return $self->_set($self->_params_prefix . ".params", $params);
+}
+
+sub get_params {
+ my ($self) = @_;
+ return unless $self->{memcached};
+
+ return $self->_get($self->_params_prefix . ".params");
+}
+
+sub clear_params {
+ my ($self, $args) = @_;
+ return unless $self->{memcached};
+ $self->_inc_prefix("params");
+}
+
sub set_bloomfilter {
my ($self, $args) = @_;
return unless $self->{memcached};
sub _prefix {
my ($self, $name) = @_;
# we don't want to change prefixes in the middle of a request
+ $name .= "/" . Bugzilla->VERSION;
my $request_cache = Bugzilla->request_cache;
my $request_cache_key = "memcached_prefix_$name";
if (!$request_cache->{$request_cache_key}) {
sub _inc_prefix {
my ($self, $name) = @_;
my $memcached = $self->{memcached};
+ $name .= "/" . Bugzilla->VERSION;
if (!$memcached->incr($name, 1)) {
$memcached->add($name, time());
}
return $_[0]->_prefix("config");
}
+sub _params_prefix {
+ return $_[0]->_prefix("params");
+}
+
sub _bloomfilter_prefix {
return $_[0]->_prefix("bloomfilter");
}