Skip to content

Commit bda3ab8

Browse files
committed
apply suggestion
1 parent dae8594 commit bda3ab8

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/CommonITILObject.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8819,9 +8819,7 @@ protected function updateActors(bool $disable_notifications = false)
88198819
? sprintf('_additional_%ss', $actor_type)
88208820
: sprintf('_additional_%ss_%ss', strtolower($actor_itemtype), $actor_type);
88218821

8822-
$actors_id_replace_input_key = $actor_itemtype === User::class
8823-
? sprintf('_replace_%ss', $actor_type)
8824-
: sprintf('_replace_%ss_%ss', strtolower($actor_itemtype), $actor_type);
8822+
$actors_id_replace_input_key = sprintf('_replace_%ss_%ss', strtolower($actor_itemtype), $actor_type);
88258823

88268824
$get_unique_key = function (array $actor) use ($actors_id_input_key): string {
88278825
// Use alternative_email in value key for "email" actors
@@ -8982,14 +8980,12 @@ protected function updateActors(bool $disable_notifications = false)
89828980

89838981
// remove all related actors
89848982
$actors_deleted_input_key = sprintf('_%s_%s_deleted', $actor_fkey, $actor_type);
8985-
foreach ($this->{"lazy_loaded_" . str_replace("_id", "", $actor_fkey)} as $current_itilobject_actor) {
8986-
foreach ($current_itilobject_actor as $actor_value) {
8987-
$this->input[$actors_deleted_input_key][] =
8988-
[
8989-
"itemtype" => $actor_itemtype,
8990-
"id" => $actor_value["id"],
8991-
];
8992-
}
8983+
$existing_actors = $this->{str_replace("_id", "", $actor_fkey)}; // `$this->users` or `$this->groups` or `$this->suppliers`
8984+
foreach ($existing_actors[$actor_type_value] as $actor_value) {
8985+
$this->input[$actors_deleted_input_key][] = [
8986+
"itemtype" => $actor_itemtype,
8987+
"id" => $actor_value["id"],
8988+
];
89938989
}
89948990

89958991

0 commit comments

Comments
 (0)