Skip to content

Commit e8d5e37

Browse files
committed
Merge branch '5.x' into 6.x
# Conflicts: # CHANGELOG.md
2 parents cdb3873 + 6371943 commit e8d5e37

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Release Notes for Feed Me
22

3-
## 6.8.0 - 2025-03-14
3+
## Unreleased
4+
5+
- Fixed an error that could occur when running a feed with nothing to process. ([#1611](https://github.com/craftcms/feed-me/pull/1611))
46

7+
## 6.8.0 - 2025-03-14
8+
-
59
- Added support for Craft’s batched queue jobs, so that long-running feeds can be processed in batches. ([#1598](https://github.com/craftcms/feed-me/pull/1598))
610
- Improved support for importing into Time fields. ([#1595](https://github.com/craftcms/feed-me/pull/1595))
711
- Fixed a PHP error that could occur with some plugins that were installed, but Feed Me doesn't support. ([#1596](https://github.com/craftcms/feed-me/pull/1596))

src/datatypes/Csv.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
112112
$array = Plugin::$plugin->data->findPrimaryElement($primaryElement, $array);
113113
}
114114

115-
$this->feedData = $array;
115+
if ($array) {
116+
$this->feedData = $array;
117+
}
118+
116119
return ['success' => true, 'data' => $array];
117120
}
118121

src/datatypes/GoogleSheet.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
8787
$array = Plugin::$plugin->data->findPrimaryElement($primaryElement, $array);
8888
}
8989

90-
$this->feedData = $array;
90+
if ($array) {
91+
$this->feedData = $array;
92+
}
93+
9194
return ['success' => true, 'data' => $array];
9295
}
9396
}

src/datatypes/Json.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
8585
$array = Plugin::$plugin->data->findPrimaryElement($primaryElement, $array);
8686
}
8787

88-
$this->feedData = $array;
88+
if ($array) {
89+
$this->feedData = $array;
90+
}
91+
8992
return ['success' => true, 'data' => $array];
9093
}
9194
}

src/datatypes/Xml.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ public function getFeed($url, $settings, bool $usePrimaryElement = true): array
8383
$array = Plugin::$plugin->data->findPrimaryElement($primaryElement, $array);
8484
}
8585

86-
$this->feedData = $array;
86+
if ($array) {
87+
$this->feedData = $array;
88+
}
89+
8790
return ['success' => true, 'data' => $array];
8891
}
8992
}

src/queue/jobs/FeedImport.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ protected function loadData(): Batchable
9393
{
9494
$feedData = $this->feed->getFeedData();
9595

96+
// Do we even have any data to process?
97+
if (!$feedData) {
98+
return new DataBatcher([]);
99+
}
100+
96101
if ($this->offset) {
97102
$feedData = array_slice($feedData, $this->offset);
98103
}
@@ -158,16 +163,23 @@ protected function processItem(mixed $item): void
158163
public function execute($queue): void
159164
{
160165
$processService = Plugin::$plugin->getProcess();
166+
$data = array_filter((array)$this->data());
167+
168+
if (empty($data)) {
169+
Plugin::info('No feed items to process.');
170+
return;
171+
}
172+
161173
if ($this->itemOffset == 0) {
162-
$processService->beforeProcessFeed($this->feed, (array)$this->data());
174+
$processService->beforeProcessFeed($this->feed, $data);
163175
}
164176

165177
if (!$this->startTime) {
166178
$this->startTime = $processService->time_start;
167179
}
168180

169181
if (empty($this->_feedSettings)) {
170-
$this->_feedSettings = $processService->getFeedSettings($this->feed, (array)$this->data());
182+
$this->_feedSettings = $processService->getFeedSettings($this->feed, $data);
171183
}
172184

173185
parent::execute($queue);

0 commit comments

Comments
 (0)