Skip to content

Commit 55bc711

Browse files
committed
#189 throw errors if no item data is retrieved from the data file
1 parent a31f3ac commit 55bc711

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Shopify
22

3+
## Unreleased
4+
5+
- Fixed a bug where syncing queue jobs could run indefinitely. ([#189](https://github.com/craftcms/shopify/issues/189))
6+
- Fixed a bug where syncing products could fail if the sync file had downloaded incorrectly.
7+
38
## 6.1.1 - 2025-11-06
49

510
- Fixed a bug where file storage could be maxed out when using multiple queue workers.

src/api/BulkDataBatcher.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ class BulkDataBatcher implements Batchable
3232
*/
3333
public function getSlice(int $offset, int $limit): iterable
3434
{
35+
if (!file_exists($this->filePath)) {
36+
throw new \Exception('File not found: ' . $this->filePath);
37+
}
38+
39+
if (filesize($this->filePath) === 0) {
40+
throw new \Exception('File is empty: ' . $this->filePath);
41+
}
42+
3543
// Seek forward in the file by the number of lines in the offset
3644
$fileObject = new \SplFileObject($this->filePath);
3745
$fileObject->seek($offset === 0 ? 0 : $offset - 1);
@@ -44,6 +52,10 @@ public function getSlice(int $offset, int $limit): iterable
4452
$i++;
4553
}
4654

55+
if (empty($lines)) {
56+
throw new \Exception('No more lines to read from the file.');
57+
}
58+
4759
return collect($lines);
4860
}
4961

0 commit comments

Comments
 (0)