Skip to content

Commit

Permalink
Revert change to get_file_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Mosnar committed Sep 25, 2024
1 parent b301e85 commit a9fef08
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/services/Compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,13 @@ public function createArchiveAsset(ArchiveRecord $archiveRecord): ?ArchiveModel
foreach ($fileAssetRecords as $fileAssetRecord) {
$assetIds[] = $fileAssetRecord->assetId;
}
$assetQuery = new AssetQuery(Asset::class);
$assetQuery->id($assetIds);
$assets = $assetQuery->all();
$assets = Asset::find()->id($assetIds)->all();
$assetName = $uuid . '.zip';
if ($archiveRecord->filename) {
$assetName = $archiveRecord->filename . '.zip';
}
$tempFileName = $uuid . '.zip';
$tempFileName = \craft\helpers\FileHelper::sanitizeFilename($tempFileName, ['separator' => null]);
$tempFileName = FileHelper::sanitizeFilename($tempFileName, ['separator' => null]);

$tempDirectory = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . 'compress';
FileHelper::createDirectory($tempDirectory);
Expand All @@ -172,8 +170,9 @@ public function createArchiveAsset(ArchiveRecord $archiveRecord): ?ArchiveModel
}
App::maxPowerCaptain();

/** @var Asset $asset */
foreach ($assets as $asset) {
$zip->addFromString($asset->filename, file_get_contents($asset->url));
$zip->addFromString($asset->filename, $asset->getContents());
}

$zip->close();
Expand Down

0 comments on commit a9fef08

Please sign in to comment.