diff --git a/src/AmiUtilityService.php b/src/AmiUtilityService.php index 2279f46..476afb1 100644 --- a/src/AmiUtilityService.php +++ b/src/AmiUtilityService.php @@ -1760,7 +1760,8 @@ public function createAmiSet(\stdClass $data) { public function preprocessAmiSet(File $file, \stdClass $data, array &$invalid = [], $strict = FALSE): array { // Use the AMI set user ID for checking access to entity operations. - $account = $data->info['uid'] == \Drupal::currentUser()->id() ? \Drupal::currentUser() : $this->entityTypeManager->getStorage('user')->load($data->info['uid']); + $uid = $data->info['uid'] ?? \Drupal::currentUser()->id(); + $account = $uid == \Drupal::currentUser()->id() ? \Drupal::currentUser() : $this->entityTypeManager->getStorage('user')->load($uid); $file_data_all = $this->csv_read($file); // We want to validate here if the found Headers match at least the diff --git a/src/Form/amiSetEntityDeleteProcessedForm.php b/src/Form/amiSetEntityDeleteProcessedForm.php index 7371499..10c66c5 100644 --- a/src/Form/amiSetEntityDeleteProcessedForm.php +++ b/src/Form/amiSetEntityDeleteProcessedForm.php @@ -85,6 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } if ($file && $data!== new \stdClass()) { // Only UUIDs you can delete will be added. + $data->info['uid'] = $this->currentUser()->id(); $uuids = $this->AmiUtilityService->getProcessedAmiSetNodeUUids($file, $data, 'delete'); if (empty($uuids)) { $form_state->setRebuild(); diff --git a/src/Form/amiSetEntityProcessForm.php b/src/Form/amiSetEntityProcessForm.php index 3852269..1aea9da 100644 --- a/src/Form/amiSetEntityProcessForm.php +++ b/src/Form/amiSetEntityProcessForm.php @@ -170,6 +170,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->createItem($data_csv); } else { + // Add 'uid' to $data->info to unify with new account loader at \Drupal\ami\AmiUtilityService::preprocessAmiSet + $data->info['uid'] = $this->currentUser()->id(); $info = $this->AmiUtilityService->preprocessAmiSet($file, $data, $invalid, FALSE); // Means preprocess set if (count($invalid)) { @@ -195,7 +197,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { return; } - foreach ($info as $item) { // We set current User here since we want to be sure the final owner of // the object is this and not the user that runs the queue