fix 'Can't call method "setup" on an undefined value' error when using into rates...
[freeside.git] / FS / FS / TicketSystem.pm
index 77d0dae..c1553f1 100644 (file)
@@ -88,7 +88,7 @@ sub _upgrade_data {
   my $CurrentUser = $RT::SystemUser;
 
   # selfservice and cron users
-  foreach my $username ('%%%SELFSERVICE_USER', 'fs_daily') {
+  foreach my $username ('%%%SELFSERVICE_USER%%%', 'fs_daily') {
     my $User = RT::User->new($CurrentUser);
     $User->Load($username);
     if (!defined($User->Id)) {
@@ -136,7 +136,8 @@ sub _upgrade_data {
 
   # Load from RT data file
   our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions,
-       @Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final);
+       @Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final,
+       %Delete_Scrips);
   my $datafile = '%%%RT_PATH%%%/etc/initialdata';
   eval { require $datafile };
   if ( $@ ) {
@@ -211,6 +212,11 @@ sub _upgrade_data {
       my ($val, $msg) = $item->Delete;
       warn "error deleting scrip: $msg\n" if !$val;
     }
+    elsif ( exists $Delete_Scrips{$c}{$a}{$t} and $item->Creator == 1 ) {
+      warn "Deleting obsolete scrip $c $a [$t]\n";
+      my ($val, $msg) = $item->Delete;
+      warn "error deleting scrip: $msg\n" if !$val;
+    }
     else {
       $scrip{$c}{$a}{$t} = $item->id;
     }