[Rt-commit] rt branch, 4.0/fix-initialdata-basedon-cf, updated. rt-4.0.5-115-g96a2716
Kevin Falcone
falcone at bestpractical.com
Wed Aug 22 19:11:35 EDT 2012
The branch, 4.0/fix-initialdata-basedon-cf has been updated
via 96a27166c7421644cbd50fdaf62dc585a2e9a529 (commit)
from d632101a84e874c77486f4d79dd27bc9bc5f6e31 (commit)
Summary of changes:
lib/RT/Handle.pm | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 96a27166c7421644cbd50fdaf62dc585a2e9a529
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Aug 22 19:09:07 2012 -0400
Add a bit of guarding on LookupType
Some initialdata files (including the test one I had lying around) rely
on the crazy code in CustomField->Create that defaults LookupType to
RT::Queue-RT::Ticket depending on other arguments. The most common way
to trigger this is to say:
Queue => 'General'
rather than
Queue => ['General']
You should specify LookupType, but this gives a better error if you
forgot.
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index e467402..7103f28 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -861,15 +861,21 @@ sub InsertData {
}
if ( $item->{'BasedOn'} ) {
- my $basedon = RT::CustomField->new($RT::SystemUser);
- my ($ok, $msg ) = $basedon->LoadByCols( Name => $item->{'BasedOn'},
- LookupType => $item->{'LookupType'} );
- if ($ok) {
- $item->{'BasedOn'} = $basedon->Id;
+ if ( $item->{'LookupType'} ) {
+ my $basedon = RT::CustomField->new($RT::SystemUser);
+ my ($ok, $msg ) = $basedon->LoadByCols( Name => $item->{'BasedOn'},
+ LookupType => $item->{'LookupType'} );
+ 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'};
+ }
} else {
- $RT::Logger->error("Unable to load $item->{BasedOn} as a $item->{LookupType} CF. Skipping BasedOn: $msg");
+ $RT::Logger->error("Unable to load CF $item->{BasedOn} because no LookupType was specified. Skipping BasedOn");
delete $item->{'BasedOn'};
}
+
}
my ( $return, $msg ) = $new_entry->Create(%$item);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list