Browse Source

Stop trying to generate the same transforms multiple times

#12274
pull/12533/head
brandonkelly 3 years ago
parent
commit
7fc7ba8b33
No known key found for this signature in database GPG Key ID: 5E86D0CED64C7093
  1. 1
      CHANGELOG.md
  2. 13
      src/queue/jobs/GeneratePendingTransforms.php

1
CHANGELOG.md

@ -2,6 +2,7 @@
## Unreleased
- Improved the performance of the “Generating pending image transforms” queue job. ([#12274](https://github.com/craftcms/cms/issues/12274))
- Deprecated `craft\helpers\DateTimeHelper::timeZoneAbbreviation()`.
- Deprecated `craft\helpers\DateTimeHelper::timeZoneOffset()`.

13
src/queue/jobs/GeneratePendingTransforms.php

@ -30,12 +30,15 @@ class GeneratePendingTransforms extends BaseJob
$assetTransformsService = Craft::$app->getAssetTransforms();
foreach ($indexIds as $i => $id) {
if ($index = $assetTransformsService->getTransformIndexModelById($id)) {
$this->setProgress($queue, $i / $totalIndexes, Craft::t('app', '{step, number} of {total, number}', [
'step' => $i + 1,
'total' => $totalIndexes,
]));
$this->setProgress($queue, $i / $totalIndexes, Craft::t('app', '{step, number} of {total, number}', [
'step' => $i + 1,
'total' => $totalIndexes,
]));
$index = $assetTransformsService->getTransformIndexModelById($id);
// Make sure it hasn't been generated yet and isn't currently in progress
if ($index && !$index->fileExists && !$index->inProgress) {
// Don't let an exception stop us from processing the rest
try {
$assetTransformsService->ensureTransformUrlByIndexModel($index);

Loading…
Cancel
Save