[Rt-commit] rt branch 5.0/dont-insert-duplicate-cfs-on-queue created. rt-5.0.3-235-gbaf8fde18a
BPS Git Server
git at git.bestpractical.com
Tue Jan 31 16:27:39 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/dont-insert-duplicate-cfs-on-queue has been created
at baf8fde18afa68991825dc5d0bbbfba618eb2133 (commit)
- Log -----------------------------------------------------------------
commit baf8fde18afa68991825dc5d0bbbfba618eb2133
Author: Jason Crome <jcrome at bestpractical.com>
Date: Mon Jan 30 16:00:20 2023 -0500
Don't add duplicate Cfs to queue when inserting data
It is possible to inadvertently add a custom field to a queue multiple
times when inserting from an initialdata file. This change prevents this
from happening.
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 5b63911441..96c833d3b4 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1343,7 +1343,31 @@ sub InsertData {
delete $item->{'BasedOn'};
}
- }
+ }
+
+ my $global_check = RT::CustomField->new( $RT::SystemUser );
+ my ($global_found, $global_msg ) = $global_check->LoadByName(
+ Name => $item->{'Name'},
+ IncludeGlobal => 1,
+ );
+ my ($queue_found, $queue_msg );
+ if( !$global_found and $apply_to ) {
+ my $queue = RT::Queue->new( $RT::SystemUser );
+ my ( $ok, $msg ) = $queue->LoadByCols( Name => $apply_to );
+ if( $ok ) {
+ my $queue_check = RT::CustomField->new( $RT::SystemUser );
+ ($queue_found, $queue_msg ) = $queue_check->LoadByName(
+ Name => $item->{'Name'},
+ LookupType => $item->{ LookupType },
+ ObjectId => $queue->id,
+ );
+ }
+ }
+ if( $global_found or $queue_found ) {
+ $RT::Logger->warn( "Custom field " . $item->{ Name }. " already exists" .
+ ( $global_found ? " globally" : " for queue $apply_to" ) . ". Skipping." );
+ next;
+ }
my ( $return, $msg ) = $new_entry->Create(%$item);
unless( $return ) {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list