diff --git a/src/datatypes/Json.php b/src/datatypes/Json.php index 4e5aa9e2..8ac78b04 100644 --- a/src/datatypes/Json.php +++ b/src/datatypes/Json.php @@ -62,6 +62,19 @@ public function getFeed($url, $settings, $usePrimaryElement = true) return ['success' => false, 'error' => $error]; } + // if we have empty keys in the array - throw an error, that's not allowed + $containsEmptyKeys = false; + array_walk_recursive($array, function($value, $key) use (&$containsEmptyKeys) { + if (trim($key) === '') { + $containsEmptyKeys = true; + } + }); + if ($containsEmptyKeys) { + $error = 'Invalid Data: data contains empty headings (keys)'; + Plugin::error($error); + return ['success' => false, 'error' => $error]; + } + // If using pagination, set it up here - we need to do this before messing around with the primary element $this->setupPaginationUrl($array, $settings); diff --git a/src/templates/feeds/_map.html b/src/templates/feeds/_map.html index dbdc27a4..bb3f5f1f 100644 --- a/src/templates/feeds/_map.html +++ b/src/templates/feeds/_map.html @@ -62,6 +62,12 @@
{{ 'Feed Me is unable to find, or parse your provided data. This usually means your URL cannot be reached from your Craft site, or your {feedType} is invalid. Check the logs, and double-check your settings.'|t('feed-me', { feedType: feed.feedType|upper }) }}
+ {% if feedMappingData.error is not empty %} + + {% endif %} +