diff options
Diffstat (limited to 'rt/etc/upgrade/4.1.1/content')
-rw-r--r-- | rt/etc/upgrade/4.1.1/content | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/rt/etc/upgrade/4.1.1/content b/rt/etc/upgrade/4.1.1/content new file mode 100644 index 000000000..f3580bdc0 --- /dev/null +++ b/rt/etc/upgrade/4.1.1/content @@ -0,0 +1,36 @@ +use strict; +use warnings; + +our @Initial = ( + sub { + require RT::ObjectScrips; + foreach my $stage ('TransactionCreate', 'TransactionBatch') { + my $applications = RT::ObjectScrips->new( RT->SystemUser ); + $applications->Limit( FIELD => 'Stage', VALUE => $stage ); + my $alias = $applications->Join( + FIELD1 => 'Scrip', + TABLE2 => 'Scrips', FIELD2 => 'id' + ); + $applications->OrderByCols( + { ALIAS => $alias, FIELD => 'Description', ORDER => 'ASC' }, + ); + my %h; my $top_so = $h{0} = 0; + while ( my $record = $applications->Next ) { + my $oid = $record->ObjectId || 0; + + my $so; + unless ( $oid ) { + %h = (); $h{0} = $so = ++$top_so; + } + else { + $so = $h{ $oid } = ($h{$oid}||$h{0}) + 1; + } + next if $record->SortOrder == $so; + + my ($status, $msg) = $record->SetSortOrder($so); + RT->Logger->error("Couldn't set sort order: $msg") + unless $status; + } + } + }, +); |