Skip to content

Commit

Permalink
Verify whether local transforms exist, regardless of what the index says
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Apr 6, 2023
1 parent 5d1db27 commit 394779c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

- The image transformer now verifies that transforms don’t exist if the index record is missing, before queuing up the transform generation, for local filesystems. ([#13052](https://github.com/craftcms/cms/issues/13052))
- `craft\elements\Asset::EVENT_BEFORE_DEFINE_URL` now sends a `craft\events\DefineAssetUrlEvent` object, rather than `craft\events\DefineUrlEvent`. ([#13018](https://github.com/craftcms/cms/issues/13018))
- `craft\web\View::renderObjectTemplate()` now trims the returned template output.
- Fixed a bug where users were “View other users’ drafts” section permissions weren’t being enforced for unpublished drafts.
Expand Down
7 changes: 4 additions & 3 deletions src/imagetransforms/ImageTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ public function getTransformUrl(Asset $asset, ImageTransform $imageTransform, bo
$index = $this->getTransformIndex($asset, $imageTransform);
$uri = str_replace('\\', '/', $this->getTransformBasePath($asset)) . $this->getTransformUri($asset, $index);

// If it's a local filesystem, double-check that the transform exists
if ($fs instanceof LocalFsInterface && $index->fileExists && !$fs->fileExists($uri)) {
$index->fileExists = false;
// If it's a local filesystem, make sure `fileExists` is accurate
if ($fs instanceof LocalFsInterface && $index->fileExists !== $fs->fileExists($uri)) {
// Flip it and save it
$index->fileExists = !$index->fileExists;
$this->storeTransformIndexData($index);
}

Expand Down

0 comments on commit 394779c

Please sign in to comment.