[Rt-commit] rt branch 5.0/post-load-check-on-config-update created. rt-5.0.2-261-gf3eca47d36
BPS Git Server
git at git.bestpractical.com
Mon Jun 13 13:30:31 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/post-load-check-on-config-update has been created
at f3eca47d36fb1664a73fa3ac5a2d3cda07775b93 (commit)
- Log -----------------------------------------------------------------
commit f3eca47d36fb1664a73fa3ac5a2d3cda07775b93
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 7 02:49:31 2022 +0800
No need to update RT_SiteConfig.pm for changes in LoadConfig methods
This is initially for the LoadConfigFromDatabase call from
t/web/admin_tools_editconfig.t, which unnecessarily wrote config
CustomFieldGroupings db update into RT_SiteConfig.pm(RT->Config->Set is
called in PostLoadCheck of the config).
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 4269e4e459..0e9ee67aa5 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -464,11 +464,14 @@ sub set_config_wrapper {
# configuration that should be written. This is necessary
# because some extensions (RTIR, for example) temporarily swap
# configuration values out and back in Mason during requests.
+
+ # No need to write configs for Set calls from LoadConfig methods
+ # like RT::Config::LoadConfigFromDatabase.
my @caller = caller(1); # preserve list context
@caller = caller(0) unless @caller;
return RT::Config::WriteSet(@_)
- if ($caller[1]||'') =~ /\.t$/;
+ if ( $caller[1] || '' ) =~ /\.t$/ && ( $caller[3] || '' ) !~ /LoadConfig/;
return $old_sub->(@_);
};
commit 11b9dede6a56509a65d98072b719530ed7834f45
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 7 03:01:48 2022 +0800
Avoid global $_ in the while block of RT::Config::WriteSet added for tests
$_ is not localized in while block, which could cause confusing issues:
my @list = qw/foo bar/;
for ( @list ) {
open my $fh, '<', 'some-readable-file' or die $!;
while ( <$fh> ) {}
}
After this, all values in @list are undef.
This is the root cause of the failed tests of
t/web/admin_tools_editconfig.t in ba92d00fae.
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 6cfb965443..4269e4e459 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -420,11 +420,11 @@ sub set_config_wrapper {
open( my $fh, '<', $tmp{'config'}{'RT'} )
or die "Couldn't open config file: $!";
my @lines;
- while (<$fh>) {
- if (not @lines or /^Set\(/) {
- push @lines, $_;
+ while (my $line = <$fh>) {
+ if (not @lines or $line =~ /^Set\(/) {
+ push @lines, $line;
} else {
- $lines[-1] .= $_;
+ $lines[-1] .= $line;
}
}
close $fh;
commit ba92d00faeaa42c0a621a02feab70a70ca4aaa6b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jun 4 05:59:37 2022 +0800
Test CustomFieldGroupings updates from web UI
diff --git a/t/web/admin_tools_editconfig.t b/t/web/admin_tools_editconfig.t
index 366bf7f596..536ce8cdaf 100644
--- a/t/web/admin_tools_editconfig.t
+++ b/t/web/admin_tools_editconfig.t
@@ -56,6 +56,14 @@ my $tests = [
new_value => '{"1":"new-outgoing-from at example.com"}',
expected => {1 => 'new-outgoing-from at example.com'},
},
+ {
+ name => 'change CustomFieldGroupings',
+ form_id => 'form-Web_interface-Base_configuration',
+ setting => 'CustomFieldGroupings',
+ new_value => '{ "RT::Ticket": [ "Grouping Name", [ "CF Name" ] ] }',
+ expected => { 'RT::Ticket' => [ 'Grouping Name', [ 'CF Name' ] ] },
+ converted => { 'RT::Ticket' => { Default => [ 'Grouping Name', [ 'CF Name' ] ] } },
+ },
];
run_test( %{$_} ) for @{$tests};
@@ -97,6 +105,7 @@ sub run_test {
# RT::Config in the test is not running in the same process as the one in the test server.
# ensure the config object in the test is up to date with the changes.
RT->Config->LoadConfigFromDatabase();
+ RT->Config->PostLoadCheck;
$m->content_like( qr/$args{setting} changed from/, 'UI indicated the value was changed' );
@@ -109,7 +118,7 @@ sub run_test {
my $rt_config_value = RT->Config->Get( $args{setting} );
is( $rt_configuration_value, stringify($args{expected}) || $args{new_value}, 'value from RT::Configuration->Load matches new value' );
- cmp_deeply( $rt_config_value, $args{expected} || $args{new_value}, 'value from RT->Config->Get matches new value' );
+ cmp_deeply( $rt_config_value, $args{converted} || $args{expected} || $args{new_value}, 'value from RT->Config->Get matches new value' );
}
sub check_transaction {
commit d9c1d01bd3865d55f15632594effc4a6ec18eb4c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Jun 4 04:32:05 2022 +0800
Call PostLoadCheck on config update via web UI to validate/convert values
E.g. in CustomFieldGroupings we support 2 data structures:
'RT::Ticket' => [ ... ]
'RT::Ticket' => { Default => [ ... ] }
The former is automatically converted to the latter in PostLoadCheck.
Not calling it could break some code that expects "RT::Ticket" value to
be a HashRef(e.g. in RT::CustomFields::LimitToGrouping).
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index afdbf72c58..be6c044c4a 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -2844,6 +2844,7 @@ sub ApplyConfigChangeToAllServerProcesses {
# first apply locally
$self->LoadConfigFromDatabase();
+ $self->PostLoadCheck;
# then notify other servers
RT->System->ConfigCacheNeedsUpdate($database_config_cache_time);
@@ -2862,6 +2863,7 @@ sub RefreshConfigFromDatabase {
$self->LoadConfigFromDatabase();
$HTML::Mason::Commands::ReloadScrubber = 1;
$database_config_cache_time = $needs_update;
+ $self->PostLoadCheck;
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list