[Rt-commit] rt branch, 4.4/serialize-json-initialdata, updated. rt-4.4.1-423-g4eb950c
Shawn Moore
shawn at bestpractical.com
Thu Mar 23 13:50:21 EDT 2017
The branch, 4.4/serialize-json-initialdata has been updated
via 4eb950c93f76df9d0d6ee701551b43a1f1040fb9 (commit)
via 8d96774da9025f801b987f6466200c23095f1abb (commit)
via 36e365538855828540777faf41e947e60df85fdf (commit)
via 23e6381912e04ee28314f18c8d55db6e794ff29a (commit)
via 84781e6a08f7a0eeccee8766e8ff68cab1bdc82d (commit)
from 71f307ee497db8c443819d50db4b3fcf4cd0699d (commit)
Summary of changes:
lib/RT/Migrate/Serializer/JSON.pm | 37 +++++++++++++++++++++++++++----------
lib/RT/Queue.pm | 2 +-
t/api/initialdata-roundtrip.t | 1 -
3 files changed, 28 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit 84781e6a08f7a0eeccee8766e8ff68cab1bdc82d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 16:27:16 2017 +0000
Don't serialized disabled OCFVs
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 6a56220..6df4c4d 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -393,7 +393,14 @@ sub CanonicalizeCustomFields {
sub CanonicalizeObjectCustomFieldValues {
my $self = shift;
- for my $record (values %{ $self->{Records}{'RT::ObjectCustomFieldValue'} }) {
+ for my $id (keys %{ $self->{Records}{'RT::ObjectCustomFieldValue'} }) {
+ my $record = $self->{Records}{'RT::ObjectCustomFieldValue'}{$id};
+
+ if ($record->{Disabled} && !$self->{FollowDisabled}) {
+ delete $self->{Records}{'RT::ObjectCustomFieldValue'}{$id};
+ next;
+ }
+
my $object = $self->_GetSerializedByRef(delete $record->{Object});
my $cf = $self->_GetSerializedByRef(delete $record->{CustomField});
commit 23e6381912e04ee28314f18c8d55db6e794ff29a
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 16:31:34 2017 +0000
Factor out repeated deep hash lookups
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 6df4c4d..bd5da78 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -252,13 +252,14 @@ sub _CanonicalizeManyToMany {
my $finalize = $args{finalize};
my $canonicalize_object = $args{canonicalize_object};
+ my $primary_records = $self->{Records}{$primary_class};
if (my $objects = delete $self->{Records}{$object_class}) {
for my $object (values %$objects) {
- my $primary = $self->{Records}{$primary_class}{ ${ $object->{$object_primary_ref} } };
+ my $primary = $primary_records->{ ${ $object->{$object_primary_ref} } };
push @{ $primary->{$primary_key} }, $object;
}
- for my $primary (values %{ $self->{Records}{$primary_class} }) {
+ for my $primary (values %$primary_records) {
@{ $primary->{$primary_key} }
= grep defined,
map &$canonicalize_object,
@@ -343,14 +344,15 @@ sub CanonicalizeUsers {
sub CanonicalizeGroups {
my $self = shift;
- for my $id (keys %{ $self->{Records}{'RT::Group'} }) {
- my $group = $self->{Records}{'RT::Group'}{$id};
+ my $records = $self->{Records}{'RT::Group'};
+ for my $id (keys %$records) {
+ my $group = $records->{$id};
# no need to serialize this because role groups are automatically
# created; but we can't exclude this in ->Observe because then we
# lose out on the group members
if ($group->{Domain} =~ /-Role$/) {
- delete $self->{Records}{'RT::Group'}{$id};
+ delete $records->{$id};
next;
}
@@ -393,11 +395,12 @@ sub CanonicalizeCustomFields {
sub CanonicalizeObjectCustomFieldValues {
my $self = shift;
- for my $id (keys %{ $self->{Records}{'RT::ObjectCustomFieldValue'} }) {
- my $record = $self->{Records}{'RT::ObjectCustomFieldValue'}{$id};
+ my $records = delete $self->{Records}{'RT::ObjectCustomFieldValue'};
+ for my $id (keys %$records) {
+ my $record = $records->{$id};
if ($record->{Disabled} && !$self->{FollowDisabled}) {
- delete $self->{Records}{'RT::ObjectCustomFieldValue'}{$id};
+ delete $records->{$id};
next;
}
@@ -411,8 +414,6 @@ sub CanonicalizeObjectCustomFieldValues {
push @{ $object->{CustomFields} }, $record;
}
-
- delete $self->{Records}{'RT::ObjectCustomFieldValue'};
}
sub CanonicalizeArticles {
commit 36e365538855828540777faf41e947e60df85fdf
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 16:54:07 2017 +0000
No need to include nobody member for single-member groups
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index bd5da78..31909b4 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -367,17 +367,26 @@ sub CanonicalizeGroups {
sub CanonicalizeGroupMembers {
my $self = shift;
- for my $record (values %{ $self->{Records}{'RT::GroupMember'} }) {
+ my $records = $self->{Records}{'RT::GroupMember'};
+ for my $id (keys %$records) {
+ my $record = $records->{$id};
my $group = $self->_GetObjectByRef(delete $record->{GroupId})->Object;
+ my $member = $self->_GetObjectByRef(delete $record->{MemberId})->Object;
my $domain = $group->Domain;
+ # no need to explicitly include a Nobody member
+ if ($member->isa('RT::User') && $member->Name eq 'Nobody' && $group->SingleMemberRoleGroup) {
+ delete $records->{$id};
+ next;
+ }
+
+
$record->{Group} = $group->Name;
$record->{GroupDomain} = $domain
unless $domain eq 'UserDefined';
$record->{GroupInstance} = \($group->InstanceObj->UID)
if $domain =~ /-Role$/;
- my $member = $self->_GetObjectByRef(delete $record->{MemberId})->Object;
$record->{Class} = ref($member);
$record->{Name} = $member->Name;
}
commit 8d96774da9025f801b987f6466200c23095f1abb
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 17:49:25 2017 +0000
Avoid undef warnings when checking a new queue for name uniqueness
This adopts the same syntactical pattern as RT::Group
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 5c51c5a..629222e 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -280,7 +280,7 @@ sub _ValidateName {
$tempqueue->Load($name);
#If this queue exists, return undef
- if ( $tempqueue->Name() && $tempqueue->id != $self->id) {
+ if ( $tempqueue->Name() && ( !$self->id || $tempqueue->id != $self->id ) ) {
return (undef, $self->loc("Queue already exists") );
}
commit 4eb950c93f76df9d0d6ee701551b43a1f1040fb9
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 23 17:50:08 2017 +0000
Remove suppressing undef warnings from initialdata-roundtrip test
diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index e8c4a0d..05ba724 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -1018,7 +1018,6 @@ for my $test (@tests) {
qr/^.* already has the right .* on .*$/,
qr/^Invalid value for Name$/,
qr/^Queue already exists$/,
- qr/^Use of uninitialized value in/,
qr/^Invalid Name \(names must be unique and may not be all digits\)$/,
);
-----------------------------------------------------------------------
More information about the rt-commit
mailing list