RT# 77917 - fixed upgrade to work when all agents were selected.
authorChristopher Burger <burgerc@freeside.biz>
Tue, 5 Jun 2018 12:50:17 +0000 (08:50 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Tue, 5 Jun 2018 12:50:17 +0000 (08:50 -0400)
FS/FS/part_event_condition_option.pm

index 15a6a55..f1d1b6a 100644 (file)
@@ -146,14 +146,23 @@ sub _upgrade_data { #class method
   unless ( FS::upgrade_journal->is_done('agentnum_to_hash') ) {
 
     foreach my $condition_option (qsearch('part_event_condition_option', { optionname => 'agentnum', })) {
+      my %options;
       my $optionvalue = $condition_option->get("optionvalue");
       if ($optionvalue eq 'HASH' ) { next; }
+      elsif ($optionvalue eq '') {
+        foreach my $agent (qsearch('agent', {})) {
+          $options{$agent->agentnum} = '1';
+        }
+
+      }
       else {
-        my $options = {"$optionvalue" => '1',};
-        $condition_option->optionvalue(ref($options));
-        my $error = $condition_option->replace($options);
-        die $error if $error;
+        $options{$optionvalue} = '1';
       }
+
+      $condition_option->optionvalue(ref(\%options));
+      my $error = $condition_option->replace(\%options);
+      die $error if $error;
+
     }
 
     FS::upgrade_journal->set_done('agentnum_to_hash');