diff --git a/classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php b/classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php index bb2ef67305b..f04760fd4e6 100644 --- a/classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php +++ b/classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php @@ -43,21 +43,26 @@ public function up(): void ->pluck('user_id', 'log_id'); $inserts = []; - foreach ($idsToUpdate as $eventLogId => $userId) { - $editorName = Repo::user()->get($userId)->getFullName(); - if ($editorName) { - $inserts[] = [ - 'log_id' => $eventLogId, - 'locale' => '', - 'setting_name' => 'editorName', - 'setting_value' => $editorName - ]; + if ($idsToUpdate) { + foreach ($idsToUpdate as $eventLogId => $userId) { + $editorName = Repo::user()->get($userId)->getFullName(); + + if ($editorName) { + $inserts[] = [ + 'log_id' => $eventLogId, + 'locale' => '', + 'setting_name' => 'editorName', + 'setting_value' => $editorName + ]; + } } } - DB::table('event_log_settings') - ->insert($inserts); + if ($inserts) { + DB::table('event_log_settings') + ->insert($inserts); + } } /**