[Rt-commit] rt branch 5.0/post-load-check-on-config-update created. rt-5.0.2-259-gba92d00fae

BPS Git Server git at git.bestpractical.com
Fri Jun 3 22:50:35 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  ba92d00faeaa42c0a621a02feab70a70ca4aaa6b (commit)

- Log -----------------------------------------------------------------
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