Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / rt / etc / upgrade / 4.1.17 / content
1 use strict;
2 use warnings;
3
4 our @Initial = (sub {
5     my $searches = RT::Attributes->new(RT->SystemUser);
6     $searches->Limit( FIELD => 'Name', VALUE => 'SavedSearch' );
7     $searches->OrderBy( FIELD => 'id' );
8
9     while (my $search = $searches->Next) {
10         my $content = $search->Content;
11         next unless ref $content eq 'HASH';
12         next unless ($content->{SearchType} || '') eq 'Chart';
13
14         # Switch from PrimaryGroupBy to GroupBy name
15         # Switch from "CreatedMonthly" to "Created.Monthly"
16         $content->{GroupBy} ||= [delete $content->{PrimaryGroupBy}];
17         for (@{$content->{GroupBy}}) {
18             next if !defined || /\./;
19             s/(?<=[a-z])(?=[A-Z])/./;
20         }
21
22         my ($ok, $msg) = $search->SetContent($content);
23         RT->Logger->error("Unable to upgrade saved chart #@{[$search->id]}: $msg")
24             unless $ok;
25     }
26 });