Skip to content

Commit

Permalink
Merge branch 'v4' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Nov 25, 2023
2 parents 6ff1dc7 + 78dd254 commit 87901f2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fixed a bug where updating entry statuses for a site in a site group, would update statuses for all sites in the site group instead of the targeted one. ([#1208](https://github.com/craftcms/feed-me/issues/1208))
- Fixed a bug where you could not use `false` to override feed settings in `config/feed-me.php`. ([#1380](https://github.com/craftcms/feed-me/issues/1380))
- Fixed a bug where importing nested element fields would not work in some scenarios. ([#1378](https://github.com/craftcms/feed-me/issues/1378))
- Fixed a bug where empty column headings in a feed would cause incorrect values to be selected in the pagination URL dropdown when mapping a feed. ([#1375](https://github.com/craftcms/feed-me/issues/1375))

## 5.2.0 - 2023-07-06

Expand Down
5 changes: 5 additions & 0 deletions src/datatypes/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
$filteredRow = [];

// Additional work here to handle line-breaks in keys (CSV header) - they're not allowed
$col = 1;
foreach ($row as $key => $value) {
$newKey = preg_replace('#\r\n?#', " ", $key);
if (trim($newKey) == '') {
$newKey = 'blank_heading_' . $col;
}
$filteredRow[$newKey] = $value;
$col++;
}

// Check for empty rows - ditch them
Expand Down
4 changes: 4 additions & 0 deletions src/datatypes/GoogleSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
foreach ($row as $j => $column) {
$key = $headers[$j];

if (trim($key) == '') {
$key = 'blank_heading_' . ($j + 1);
}

$array[$i][$key] = $column;
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/datatypes/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
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);

Expand Down
6 changes: 6 additions & 0 deletions src/templates/feeds/_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<h2>{{ 'Unable to proceed to field mapping'|t('feed-me') }}</h2>
<p>{{ '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 }) }}</p>

{% if feedMappingData.error is not empty %}
<div class="fullpage-error-message">
<code>{{ feedMappingData.error }}</code>
</div>
{% endif %}

<div class="buttons">
<a href="{{ url('feed-me/feeds/' ~ feed.id) }}" class="btn submit">&larr; {{ 'Back to feed'|t('feed-me') }}</a>
<a href="{{ url('feed-me/logs') }}" class="btn submit">{{ 'Go to logs'|t('feed-me') }}</a>
Expand Down

0 comments on commit 87901f2

Please sign in to comment.