From a24f58d3d8eff39d91368057801d33d2ae86fcd1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 1 Mar 2023 10:14:25 +1100 Subject: [PATCH] Fixes for unequal array combinations when mergins CSV imports --- VERSION.txt | 2 +- app/Import/Providers/BaseImport.php | 17 +++++++++++++++++ app/Jobs/Import/CSVIngest.php | 2 +- config/ninja.php | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 9de379774e28..1885318d63c4 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.76 \ No newline at end of file +5.5.77 \ No newline at end of file diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index 1d1954dfa0c5..758c12a8ef67 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -54,6 +54,14 @@ class BaseImport public $transformer; + public ?array $column_map = []; + + public ?string $hash; + + public ?string $import_type; + + public ?bool $skip_header; + public function __construct(array $request, Company $company) { $this->company = $company; @@ -78,6 +86,7 @@ class BaseImport public function getCsvData($entity_type) { $base64_encoded_csv = Cache::pull($this->hash.'-'.$entity_type); + if (empty($base64_encoded_csv)) { return null; } @@ -636,6 +645,14 @@ class BaseImport ksort($keys); $data = array_map(function ($row) use ($keys) { + + $row_count = count($row); + $key_count = count($keys); + + if($key_count > $row_count) { + $row = array_pad($row, $key_count, ' '); + } + return array_combine($keys, array_intersect_key($row, $keys)); }, $data); diff --git a/app/Jobs/Import/CSVIngest.php b/app/Jobs/Import/CSVIngest.php index cdeaab860c28..e34629d7524c 100644 --- a/app/Jobs/Import/CSVIngest.php +++ b/app/Jobs/Import/CSVIngest.php @@ -42,7 +42,7 @@ class CSVIngest implements ShouldQueue public ?string $skip_header; - public $column_map; + public ?array $column_map = []; public array $request; diff --git a/config/ninja.php b/config/ninja.php index b3da052a2a64..cf403ccda892 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.76', - 'app_tag' => '5.5.76', + 'app_version' => '5.5.77', + 'app_tag' => '5.5.77', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),