From c98541996c5336fb02ffd358cc6bda3b2dcdfc4d Mon Sep 17 00:00:00 2001 From: Sagar Date: Thu, 19 Feb 2026 18:44:48 +0100 Subject: [PATCH] fix: array out of bounds error. --- .../ImportEntriesAuto.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/SubmissionsAutoProcess/ImportEntriesAuto.php b/app/Console/Commands/SubmissionsAutoProcess/ImportEntriesAuto.php index 9dea7d9d..9870804b 100644 --- a/app/Console/Commands/SubmissionsAutoProcess/ImportEntriesAuto.php +++ b/app/Console/Commands/SubmissionsAutoProcess/ImportEntriesAuto.php @@ -567,12 +567,21 @@ public function attachCollection($molecule, $entry, &$auditRecords) $newComment = $entry->structural_comments ?? ''; $combinationExists = false; - for ($i = 0; $i < count($existingReferences); $i++) { + // Get the maximum count to ensure we check all possible positions + $maxCount = max( + count($existingReferences), + count($existingUrls), + count($existingFilenames), + count($existingComments) + ); + + for ($i = 0; $i < $maxCount; $i++) { if ( - $existingReferences[$i] === $newReference && - $existingUrls[$i] === $newUrl && - $existingFilenames[$i] === $newFilename && - $existingComments[$i] === $newComment + ($existingReferences[$i] ?? '') === $newReference && + ($existingUrls[$i] ?? '') === $newUrl && + ($existingFilenames[$i] ?? '') === $newFilename && + ($existingComments[$i] ?? '') === $newComment + ) { $combinationExists = true; break;