From 22d7d2a04ef54d5c738bb628a29d0dafe21f73f9 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Wed, 8 Mar 2023 13:56:29 -0800 Subject: [PATCH] Aliases could get selected when they weren't for an import_type --- app/Http/Livewire/ImporterFile.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Livewire/ImporterFile.php b/app/Http/Livewire/ImporterFile.php index e67f37f49..2f5bf8d94 100644 --- a/app/Http/Livewire/ImporterFile.php +++ b/app/Http/Livewire/ImporterFile.php @@ -172,8 +172,13 @@ class ImporterFile extends Component foreach(self::$aliases as $key => $alias_values) { foreach($alias_values as $alias_value) { if (strcasecmp($alias_value,$header) === 0) { // aLsO CaSe-INSENSitiVE! - $this->field_map[$i] = $key; - continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header + // Make *absolutely* sure that this key actually _exists_ in this import type - + // you can trigger this by importing accessories with a 'Warranty' column (which don't exist + // in "Accessories"!) + if (array_key_exists($key, $this->columnOptions[$new_import_type])) { + $this->field_map[$i] = $key; + continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header + } } } }