Skip to content

Commit

Permalink
Merge branch '5.x' into 6.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
angrybrad committed Nov 27, 2024
2 parents 4bee795 + 89d0a96 commit 7e0ec3d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added the `assetDownloadGuzzle` config setting which defaults to `false`. When it is set to `true`, Feed Me will use Guzzle to download assets instead curl directly. ([#1549](https://github.com/craftcms/feed-me/pull/1549))
- Imported Commerce Products now add a single Catalog Pricing job to the queue after an import, instead of one per Product. ([#1547](https://github.com/craftcms/feed-me/pull/1547))

## 6.5.0 - 2024-10-15
Expand Down
1 change: 1 addition & 0 deletions docs/get-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ return [
- `queueTtr` — Set the 'time to reserve' time in seconds, to prevent the job being cancelled after 300 seconds (default).
- `queueMaxRetry` — Set the maximum amount of retries the queue job should have before failing.
- `assetDownloadCurl` — Use curl to download assets from a remote source. Can be used when issues arise using the default implementation.
- `assetDownloadGuzzle` — Use Guzzle to download assets from a remote source. Can be used when issues arise using the default implementation.
- `feedOptions` — Provide an array of any of the above options (or [feed settings](../feature-tour/feed-overview.md)) to set or override for specific feeds, keyed by their existing feed IDs. _Note that feed IDs may be different across environments!_

#### Example `requestOptions`
Expand Down
17 changes: 16 additions & 1 deletion src/helpers/AssetHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,25 @@ public static function downloadFile($srcName, $dstName, int $chunkSize = 1, bool
return fclose($fp);
}

$fp = fopen($dstName, 'wb');

$assetDownloadGuzzle = Plugin::$plugin->service->getConfig('assetDownloadGuzzle', $feedId);
if ($assetDownloadGuzzle) {
$response = null;
$client = Plugin::$plugin->service->createGuzzleClient();
try {
$response = $client->get($srcName, ['sink' => $fp]);
} catch (Throwable $e) {
}

fclose($fp);

return $response?->getStatusCode() === 200;
}

$newChunkSize = $chunkSize * (1024 * 1024);
$bytesCount = 0;
$handle = fopen($srcName, 'rb');
$fp = fopen($dstName, 'wb');

if ($handle === false) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,10 @@ class Settings extends Model
* @var bool
*/
public bool $assetDownloadCurl = false;

/**
* @var bool
* @since 5.9.0
*/
public bool $assetDownloadGuzzle = false;
}

0 comments on commit 7e0ec3d

Please sign in to comment.