[Rt-commit] rt branch, 4.4/serialize-json-initialdata, updated. rt-4.4.1-416-gbaf070e
Shawn Moore
shawn at bestpractical.com
Wed Mar 22 18:27:05 EDT 2017
The branch, 4.4/serialize-json-initialdata has been updated
via baf070eec607f951fe24e24a4fda0e93ade0a368 (commit)
via b1ddc959291c8ef28d0716a5a567bcd16626e87d (commit)
via f0c6fe763e8387d600efbab1daadcfc270db62c0 (commit)
from 7e77918f54a2cf839e4764f8284568e765ea543e (commit)
Summary of changes:
lib/RT/Handle.pm | 22 ++++++++++++++++++++--
lib/RT/Migrate/Serializer/JSON.pm | 7 +++++++
2 files changed, 27 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit f0c6fe763e8387d600efbab1daadcfc270db62c0
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Mar 22 21:54:37 2017 +0000
Handle disabled OCFVs by skipping them
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index cb51185..fbd6e1d 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -429,6 +429,8 @@ sub CanonicalizeObjects {
primary_key => 'Values',
canonicalize_object => sub {
my %object = %$_;
+ return if $object{Disabled} && !$self->{FollowDisabled};
+
delete @object{qw/id CustomField/};
delete $object{Category} if !length($object{Category});
delete $object{Description} if !length($object{Description});
commit b1ddc959291c8ef28d0716a5a567bcd16626e87d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Mar 22 21:57:11 2017 +0000
Remove empty user keys
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index fbd6e1d..0aabc36 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -325,6 +325,11 @@ sub CanonicalizeUsers {
my $object = RT::User->new(RT->SystemUser);
$object->Load($user->{id});
+ for my $key (keys %$user) {
+ my $value = $user->{$key};
+ delete $user->{$key} if !defined($value) || !length($value);
+ }
+
$user->{Privileged} = $object->Privileged ? JSON::true : JSON::false;
}
}
commit baf070eec607f951fe24e24a4fda0e93ade0a368
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Mar 22 22:17:10 2017 +0000
Defer setting BasedOn for CFs later in the @CustomFields list
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index e7239d1..4a322fe 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1183,6 +1183,8 @@ sub InsertData {
if ( @CustomFields ) {
$RT::Logger->debug("Creating custom fields...");
+ my @deferred_BasedOn;
+
for my $item ( @CustomFields ) {
my $attributes = delete $item->{ Attributes };
my $new_entry = RT::CustomField->new( RT->SystemUser );
@@ -1210,8 +1212,7 @@ sub InsertData {
if ($ok) {
$item->{'BasedOn'} = $basedon->Id;
} else {
- $RT::Logger->error("Unable to load $item->{BasedOn} as a $item->{LookupType} CF. Skipping BasedOn: $msg");
- delete $item->{'BasedOn'};
+ push @deferred_BasedOn, [$new_entry, delete $item->{'BasedOn'}];
}
} else {
$RT::Logger->error("Unable to load CF $item->{BasedOn} because no LookupType was specified. Skipping BasedOn");
@@ -1268,6 +1269,23 @@ sub InsertData {
push @Attributes, @{$attributes || []};
}
+ for ( @deferred_BasedOn ) {
+ my ($cf, $name) = @$_;
+ my $basedon = RT::CustomField->new($RT::SystemUser);
+ my ($ok, $msg ) = $basedon->LoadByCols(
+ Name => $name,
+ LookupType => $cf->LookupType,
+ Disabled => 0,
+ );
+ if ($ok) {
+ ($ok, $msg) = $cf->SetBasedOn($basedon->Id);
+ $RT::Logger->error("Unable to set $name as a " . $cf->LookupType . " BasedOn CF: $msg") if !$ok;
+ }
+ else {
+ $RT::Logger->error("Unable to load $name as a " . $cf->LookupType . " CF. Skipping BasedOn: $msg");
+ }
+ }
+
$RT::Logger->debug("done.");
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list