From 8d6a3daea1e4405da65f98bd0becb12a81743df4 Mon Sep 17 00:00:00 2001 From: olivierbon Date: Fri, 24 Nov 2023 09:19:37 +0100 Subject: [PATCH 1/4] Part 2 of 1346 --- CHANGELOG.md | 1 + src/services/Fields.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5159e79..aeea16ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed a bug where `queueTtr`, `queueMaxRetry`, and `assetDownloadCurl` settings were being ignored if you used a `config/feed-me.php` config file. ([#1356](https://github.com/craftcms/feed-me/issues/1356)) - Fixed a PHP error that could occur when you map an entry field with a default value and there is an empty value in the feed. ([#1250](https://github.com/craftcms/feed-me/pull/1250)) - Fixed a bug where the `maxRelations` setting was not being respected for relational fields. ([#1354](https://github.com/craftcms/feed-me/issues/1354)) +- Part 2 of ([1346](https://github.com/craftcms/feed-me/pull/1346)). Only cater for Categories and Tags fields. ## 5.2.0 - 2023-07-06 diff --git a/src/services/Fields.php b/src/services/Fields.php index f2a2d303..9219505b 100644 --- a/src/services/Fields.php +++ b/src/services/Fields.php @@ -210,7 +210,10 @@ public function parseField($feed, $element, $feedData, $fieldHandle, $fieldInfo) // if it hasn't changed - proceed as before // if it has changed - assume that we've entrified and adjust the $fieldClassHandle $field = Craft::$app->getFields()->getFieldByHandle($fieldHandle); - if (!$field instanceof $fieldClassHandle) { + if ( + !$field instanceof $fieldClassHandle && + ($field instanceof \craft\fields\Categories || $field instanceof \craft\fields\Tags) + ) { $fieldClassHandle = \craft\fields\Entries::class; } From 9c100465c28610393ac5d36784f4e365cf7ff2cf Mon Sep 17 00:00:00 2001 From: olivierbon Date: Mon, 27 Nov 2023 10:04:31 +0100 Subject: [PATCH 2/4] Adjust for Super Table and Matrix --- src/fields/Matrix.php | 5 ++++- src/fields/SuperTable.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index dd231357..79cfa72f 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -272,7 +272,10 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if (!$subField instanceof $subFieldClassHandle) { + if ( + !$subField instanceof $subFieldClassHandle && + $subField instanceof \craft\fields\Matrix + ) { $subFieldClassHandle = \craft\fields\Entries::class; } diff --git a/src/fields/SuperTable.php b/src/fields/SuperTable.php index ad6c18cb..02a6039d 100644 --- a/src/fields/SuperTable.php +++ b/src/fields/SuperTable.php @@ -224,7 +224,10 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if (!$subField instanceof $subFieldClassHandle) { + if ( + !$subField instanceof $subFieldClassHandle && + $subField instanceof \verbb\supertable\fields\SuperTableField + ) { $subFieldClassHandle = \craft\fields\Entries::class; } From 43914a893dc64fa06d5fbca77915f9c89da2c79f Mon Sep 17 00:00:00 2001 From: olivierbon Date: Mon, 27 Nov 2023 10:13:16 +0100 Subject: [PATCH 3/4] Correct "Adjust for Super Table and Matrix" Corrects commit 9c100465c28610393ac5d36784f4e365cf7ff2cf. --- src/fields/Matrix.php | 5 +---- src/fields/SuperTable.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index 79cfa72f..dd231357 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -272,10 +272,7 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if ( - !$subField instanceof $subFieldClassHandle && - $subField instanceof \craft\fields\Matrix - ) { + if (!$subField instanceof $subFieldClassHandle) { $subFieldClassHandle = \craft\fields\Entries::class; } diff --git a/src/fields/SuperTable.php b/src/fields/SuperTable.php index 02a6039d..ad6c18cb 100644 --- a/src/fields/SuperTable.php +++ b/src/fields/SuperTable.php @@ -224,10 +224,7 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if ( - !$subField instanceof $subFieldClassHandle && - $subField instanceof \verbb\supertable\fields\SuperTableField - ) { + if (!$subField instanceof $subFieldClassHandle) { $subFieldClassHandle = \craft\fields\Entries::class; } From 7a0913a82a18c8d1fc2cb76ac3eb5382b7c392d6 Mon Sep 17 00:00:00 2001 From: olivierbon Date: Mon, 27 Nov 2023 10:13:30 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A4=A6=F0=9F=8F=BB=E2=80=8D=E2=99=82?= =?UTF-8?q?=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fields/Matrix.php | 5 ++++- src/fields/SuperTable.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index dd231357..77d69ea3 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -272,7 +272,10 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if (!$subField instanceof $subFieldClassHandle) { + if ( + !$subField instanceof $subFieldClassHandle && + ($subField instanceof \craft\fields\Categories || $subField instanceof \craft\fields\Tags) + ) { $subFieldClassHandle = \craft\fields\Entries::class; } diff --git a/src/fields/SuperTable.php b/src/fields/SuperTable.php index ad6c18cb..6a0f4167 100644 --- a/src/fields/SuperTable.php +++ b/src/fields/SuperTable.php @@ -224,7 +224,10 @@ private function _parseSubField($feedData, $subFieldHandle, $subFieldInfo): mixe $subField = Hash::extract($this->field->getBlockTypeFields(), '{n}[handle=' . $subFieldHandle . ']')[0]; - if (!$subField instanceof $subFieldClassHandle) { + if ( + !$subField instanceof $subFieldClassHandle && + ($subField instanceof \craft\fields\Categories || $subField instanceof \craft\fields\Tags) + ) { $subFieldClassHandle = \craft\fields\Entries::class; }