From 88f7d027cebcb4292339ab148bed20def1e52234 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Wed, 25 Sep 2024 17:44:25 -0700 Subject: [PATCH 1/3] 5.8.0 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8228dd..97c8ca0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Release Notes for Feed Me -## Unreleased +## 5.8.0 - 2024-09-25 + - Added support for importing into relational fields that have custom sources selected. ([#1504](https://github.com/craftcms/feed-me/pull/1504)) - Fixed a bug that could occur when uploading files to an Assets field from an external URL and a new filename is provided, but we can't determine the remote file's extension. ([#1506](https://github.com/craftcms/feed-me/pull/1506)) - Fixed a bug where the fields available to map within a given Entries field could not match the fields from that Entry type's field layout. ([#1503](https://github.com/craftcms/feed-me/pull/1503)) From f1828dca541253184fe6dfc3b1cfac934393de1a Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Wed, 9 Oct 2024 11:57:35 +0100 Subject: [PATCH 2/3] tweak when the block is considered empty --- src/fields/Matrix.php | 9 +++++++-- src/fields/SuperTable.php | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index 77d69ea3..fbafbde8 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -170,11 +170,16 @@ public function parseField(): mixed $index = 1; $resultBlocks = []; foreach ($expanded as $blockData) { - // all the fields are empty and setEmptyValues is off, ignore the block + // if all the fields are empty and setEmptyValues is off, ignore the block if ( !empty(array_filter( $blockData['fields'], - fn($value) => (is_string($value) && !empty($value)) || (is_array($value) && !empty(array_filter($value))) + fn($value) => ( + (is_string($value) && !empty($value)) || + (is_array($value) && !empty(array_filter($value))) || + is_bool($value) || + is_numeric($value) + ) )) ) { $resultBlocks['new' . $index++] = $blockData; diff --git a/src/fields/SuperTable.php b/src/fields/SuperTable.php index 229da422..b1c2386d 100644 --- a/src/fields/SuperTable.php +++ b/src/fields/SuperTable.php @@ -148,7 +148,13 @@ public function parseField(): mixed $preppedData[$blockIndex . '.enabled'] = true; $preppedData[$blockIndex . '.fields.' . $subFieldHandle] = $value; - if ((is_string($value) && !empty($value)) || (is_array($value) && !empty(array_filter($value)))) { + // if all the fields are empty and setEmptyValues is off, ignore the block + if ( + (is_string($value) && !empty($value)) || + (is_array($value) && !empty(array_filter($value))) || + is_bool($value) || + is_numeric($value) + ) { $allEmpty = false; } From 08f5c318e936a436800b1c42846d5dcf193a17a4 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Wed, 9 Oct 2024 14:37:31 -0700 Subject: [PATCH 3/3] Changelog for https://github.com/craftcms/feed-me/pull/1529 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c8ca0a..7aba1298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Feed Me +## Unreleased + +- Fixed a bug where Lightswitch fields would not import correctly when nested in a Matrix or Super Table field. ([#1529](https://github.com/craftcms/feed-me/pull/1529)) + ## 5.8.0 - 2024-09-25 - Added support for importing into relational fields that have custom sources selected. ([#1504](https://github.com/craftcms/feed-me/pull/1504))