Commit 2aeba468 authored by Brian B's avatar Brian B Committed by Marcin Grabias
Browse files

Issue #3216584 by segi, bbeversdorf: Unable to cancel a user account if it has more then 10 content

parent 86fea967
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -103,13 +103,22 @@ class CancelUserAction extends ViewsBulkOperationsActionBase implements Containe
        ]);
        ]);
      }
      }


      // Cancel the account.
      // Finish the batch and actually cancel the account.
      \_user_cancel($this->configuration, $account, $this->configuration['user_cancel_method']);
      $batch = [
        'title' => t('Cancelling user account'),
        'operations' => [
          ['_user_cancel', [$this->configuration, $account, $this->configuration['user_cancel_method']]],
        ],
      ];


      // If current user was cancelled, logout.
      // After cancelling account, ensure that user is logged out.
      if ($account->id() == $this->currentUser->id()) {
      if ($account->id() == \Drupal::currentUser()->id()) {
        \_user_cancel_session_regenerate();
        // Batch API stores data in the session, so use the finished operation to
        // manipulate the current user's session id.
        $batch['finished'] = '_user_cancel_session_regenerate';
      }
      }

      batch_set($batch);
    }
    }
  }
  }