RT#14829: automatic payments triggered by bill now show up as Payment by fs_queue...
authorJonathan Prykop <jonathan@freeside.biz>
Mon, 24 Aug 2015 22:23:33 +0000 (17:23 -0500)
committerJonathan Prykop <jonathan@freeside.biz>
Mon, 24 Aug 2015 22:23:33 +0000 (17:23 -0500)
FS/FS/queue.pm
FS/bin/freeside-queued

index f7f0948..67d124d 100644 (file)
@@ -364,19 +364,20 @@ sub update_statustext {
   #'';
 }
 
-=item access_user
-
-Returns FS::access_user object (if any) associated with this user.
-
-Returns nothing if not found.
-
-=cut
-
-sub access_user {
-  my $self = shift;
-  my $usernum = $self->usernum || return ();
-  return qsearchs('access_user',{ 'usernum' => $usernum }) || ();
-}
+# not needed in 4
+#=item access_user
+#
+#Returns FS::access_user object (if any) associated with this user.
+#
+#Returns nothing if not found.
+#
+#=cut
+#
+#sub access_user {
+#  my $self = shift;
+#  my $usernum = $self->usernum || return ();
+#  return qsearchs('access_user',{ 'usernum' => $usernum }) || ();
+#}
 
 =back
 
index 398b03d..36871b2 100644 (file)
@@ -218,13 +218,12 @@ while (1) {
       # don't put @args in the log, may expose passwords
       $log->info('starting job ('.$ljob->job.')');
       warn 'running "&'. $ljob->job. '('. join(', ', @args). ")\n" if $DEBUG;
-      # switch user only if a job user is available
-      my $oldCurrentUser = $FS::CurrentUser::CurrentUser;
-      my $jobuser = $ljob->access_user;
-      local $FS::CurrentUser::CurrentUser = $jobuser if $jobuser;
       local $FS::UID::AutoCommit = 0; # so that we can clean up failures
-      eval $eval; #throw away return value?  suppose so
-      $FS::CurrentUser::CurrentUser = $oldCurrentUser if $jobuser;
+      do {
+        # switch user only if a job user is available
+        local $FS::CurrentUser::CurrentUser = $ljob->access_user || $FS::CurrentUser::CurrentUser;
+        eval $eval; #throw away return value?  suppose so
+      };
       if ( $@ ) {
         dbh->rollback;
         my %hash = $ljob->hash;