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;