[Bps-public-commit] r18770 - RT-Extension-ExtractCustomFieldValues/lib/RT/Action
alexmv at bestpractical.com
alexmv at bestpractical.com
Thu Mar 12 17:30:05 EDT 2009
Author: alexmv
Date: Thu Mar 12 17:30:04 2009
New Revision: 18770
Modified:
RT-Extension-ExtractCustomFieldValues/lib/RT/Action/ExtractCustomFieldValues.pm
Log:
Fix for loading of disabled custom fields with the same name
Modified: RT-Extension-ExtractCustomFieldValues/lib/RT/Action/ExtractCustomFieldValues.pm
==============================================================================
--- RT-Extension-ExtractCustomFieldValues/lib/RT/Action/ExtractCustomFieldValues.pm (original)
+++ RT-Extension-ExtractCustomFieldValues/lib/RT/Action/ExtractCustomFieldValues.pm Thu Mar 12 17:30:04 2009
@@ -91,13 +91,16 @@
my %args = @_;
my $CustomFieldName = $args{Field};
my $Queue = $args{Queue};
-
$RT::Logger->debug("load cf $CustomFieldName");
- my $cf = RT::CustomField->new($RT::SystemUser);
- $cf->LoadByNameAndQueue( Name => $CustomFieldName, Queue => $Queue );
- $cf->LoadByNameAndQueue( Name => $CustomFieldName, Queue => 0 )
- unless $cf->id;
+ # We do this by hand instead of using LoadByNameAndQueue because
+ # that can find disabled queues
+ my $cfs = RT::CustomFields->new($RT::SystemUser);
+ $cfs->LimitToGlobalOrQueue( $Queue );
+ $cfs->Limit( FIELD => 'Name', VALUE => $CustomFieldName, CASESENSITIVE => 0);
+ $cfs->RowsPerPage(1);
+
+ my $cf = $cfs->First;
if ( $cf->id ) {
$RT::Logger->debug( "load cf done: " . $cf->id );
} elsif ( not $args{Quiet} ) {
@@ -114,6 +117,7 @@
= lc $args{Field} eq "body"
? $args{Attachment}->Content
: $args{Attachment}->GetHeader( $args{Field} );
+ return unless defined $content;
while ( $content =~ /$args{Match}/mg ) {
my ( $cf, $value ) = ( $1, $2 );
$cf = LoadCF( Field => $cf, Queue => $args{Queue}, Quiet => 1 );
More information about the Bps-public-commit
mailing list