6 # We do the delete in pure SQL because Attribute collections
7 # otherwise attempt to hash everything in memory. As this may
8 # be a large list, do it directly.
9 RT->DatabaseHandle->dbh->do(<<EOSQL);
10 DELETE FROM Attributes
11 WHERE Name = 'DeferredRecipients'
16 # Remove globally-granted role rights which couldn't also apply
17 # to some other object. That is, globally granting that
18 # AdminCcs have SuperUser makes no sense.
20 # Find rights which apply globally
22 my @rights = sort map {$_->{Name}} values %{$RT::ACE::RIGHTS{'RT::System'}};
24 # Those are not allowed to be granted on global role groups
25 my $invalid = RT::ACL->new( RT->SystemUser );
26 $invalid->LimitToObject( 'RT::System' );
27 $invalid->LimitToPrincipal( Id => RT::System->RoleGroup($_)->PrincipalId )
28 for RT::System->Roles;
29 $invalid->Limit( FIELD => 'RightName', OPERATOR => 'IN', VALUE => \@rights );
31 return unless $invalid->Count;
33 # Remove them, warning in the process
34 $RT::Logger->warning("There are invalid global role rights; removing:");
35 while (my $right = $invalid->Next) {
36 $RT::Logger->warning(" ".$right->RightName." granted globally to ".$right->PrincipalObj->Object->Name);
37 my ($ok, $msg) = $right->Delete;
38 $RT::Logger->error("Failed to remove right ".$right->id.": $msg") unless $ok;
42 my $txns = RT::Transactions->new(RT->SystemUser);
43 $txns->Limit( FIELD => 'Type', VALUE => 'Forward Transaction' );
44 $txns->Limit( FIELD => 'Type', VALUE => 'Forward Ticket' );
45 while ( my $txn = $txns->Next ) {
46 my $att = $txn->Attachments->First;
49 # we only need to process ascii-only strings
50 unless ( $att->Subject =~ /[^\x00-\x7F]/ ) {
51 $att->__Set( Field => 'Subject', Value => Encode::decode("UTF-8", RT::I18N::DecodeMIMEWordsToUTF8($att->Subject, 'Subject')) );
53 for my $field ( qw/Subject From To Cc Bcc/ ) {
54 next if !$att->GetHeader($field) || $att->GetHeader($field) =~ /[^\x00-\x7F]/;
55 # Subject here is not a typo, because we don't really want to parse email addresses here
56 $att->SetHeader( $field, Encode::decode("UTF-8", RT::I18N::DecodeMIMEWordsToUTF8($att->GetHeader($field), 'Subject')) );