[Rt-commit] rt branch, 4.6/log-view-db-config-change-history, repushed
Aaron Trevena
ast at bestpractical.com
Fri Mar 27 09:49:04 EDT 2020
The branch 4.6/log-view-db-config-change-history was deleted and repushed:
was 635e497a3071d2c176c9e8ed937347ac144f0945
now e3bd093371d75119fe9a0eaeaff25eba52c6d4a9
1: 039be68775 = 1: 039be68775 Schema updates for tracking db configuration changes in transactions
2: f5de477e2b ! 2: f6f43cfd15 Log DB config changes as transactions
@@ -170,32 +170,38 @@
- $old_value = $self->loc('(no value)');
- }
-
-- if (ref $value) {
++ my $value = $raw_value;
+ if (ref $value) {
- ($value, my $error) = $self->_SerializeContent($value);
- if ($error) {
- return (0, $error);
-- }
++ ($value, $msg) = $self->_SerializeContent($self->Content, $self->Name);
++ if ($msg) {
++ return (0, $msg);
+ }
- $content_type = 'perl';
-+ $RT::Handle->BeginTransaction;
++ }
++ if ($self->Content eq $value) {
++ return (0, $self->loc("[_1] update: Nothing changed", ucfirst($self->Name)));
+ }
+
+ $RT::Handle->BeginTransaction;
+ ( $ok, $msg ) = $self->SetDisabled( 1 );
+ unless ($ok) {
+ $RT::Handle->Rollback;
+ return ($ok, $msg);
- }
-
-- $RT::Handle->BeginTransaction;
++ }
+
+- ($ok, $msg) = $self->_Set( Field => 'Content', Value => $value );
+- if (!$ok) {
+ my ($old_value, $error) = $self->Content;
+ my $old_id = $self->id;
+ my ( $new_id, $new_msg ) = $self->_Create(
+ Name => $self->Name,
+ Content => $raw_value,
+ ContentType => $content_type,
-+ _Replace => 1
-+ );
-
-- ($ok, $msg) = $self->_Set( Field => 'Content', Value => $value );
-- if (!$ok) {
-+ my $value = $self->Content;
++ );
++
+ unless ($new_id) {
$RT::Handle->Rollback;
- return ($ok, $self->loc("Unable to update [_1]: [_2]", $self->Name, $msg));
@@ -252,8 +258,11 @@
Documented for internal use only, do not call these from outside
RT::Configuration itself.
-+
+=head2 _Create
++
++Checks that the field being created/updated is not immutable, before calling
++C<SUPER::Create> to save changes in a new row, returning id of new row on success
++ and 0, and message on failure.
+
+=cut
+
@@ -263,7 +272,6 @@
+ Name => '',
+ Content => '',
+ ContentType => '',
-+ _Replace => 0,
+ @_
+ );
+ my $meta = RT->Config->Meta($args{'Name'});
@@ -277,12 +285,6 @@
+ return (0, $error);
+ }
+ $args{'ContentType'} = 'perl';
-+ }
-+
-+ if ($args{'_Replace'}) {
-+ if ($self->Content eq $args{'Content'}) {
-+ return (0, $self->loc("[_1] update: Nothing changed", ucfirst($args{'Name'})));
-+ }
+ }
+
+ my ( $id, $msg ) = $self->SUPER::Create(
3: e348355d09 = 3: 2f97a2d642 Remove unused stringify function in configuration edit page
4: 2ec4d0a035 = 4: ea8a4c833a Page to view DB config transaction history
5: 635e497a30 ! 5: e3bd093371 Tests for DB config transactions and history
@@ -41,6 +41,11 @@
my %args = @_;
@@
+
+ my $rt_config_value = RT->Config->Get( $args{setting} );
+
+- cmp_deeply( $rt_configuration_value, stringify($args{new_value}), 'value from RT::Configuration->Load matches new value' );
++ is( $rt_configuration_value, stringify($args{new_value}), 'value from RT::Configuration->Load matches new value' );
cmp_deeply( $rt_config_value, $args{new_value}, 'value from RT->Config->Get matches new value' );
}
@@ -55,10 +60,23 @@
+ my ($tx, $change) = @_;
+ my $link = sprintf('ConfigHistory.html?id=%d#txn-%d', $tx->ObjectId,$tx->id);
+ ok($m->find_link(url => $link), 'found tx link in history');
-+ $m->content_contains(stringify($change->{new_value}), 'fetched tx has new value');
++ $m->text_like(regexify($change->{new_value}), 'fetched tx has new value');
+ $m->content_contains( "$change->{setting} changed from", 'fetched tx has changed field');
++}
++
++sub regexify {
++ my $value = stringify(shift);
++ $value =~ s/(\x{0a}|\n|\s+)/\\s\*/g;
++ return qr($value);
+}
+
sub stringify {
my $value = shift;
+ return $value unless ref $value;
+
+ local $Data::Dumper::Terse = 1;
+- local $Data::Dumper::Indent = 2;
+ local $Data::Dumper::Sortkeys = 1;
+
+ my $output = Data::Dumper::Dumper $value;
More information about the rt-commit
mailing list