Skip to content

[6.x] Remove maxCachedCloudImageSize - #20780

Open
timkelty wants to merge 2 commits into
remove-ephemeral-environmentfrom
remove-max-cached-cloud-image-size
Open

timkelty wants to merge 2 commits into
remove-ephemeral-environmentfrom
remove-max-cached-cloud-image-size

Conversation

@timkelty

@timkelty timkelty commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

maxCachedCloudImageSize conflates two decisions: whether Craft keeps a local copy of a remote image after using it, and whether it downscales that copy before transforming it. It also silently decides whether the Asset Indexes "Cache remote images" option does anything, since it defaults to 0.

Stacked on #20547.

Stack meeting notes: https://github.com/craftcms/cms/stack/20789

 getLocalImageSource($asset)
   download original to storage
-  if maxCachedCloudImageSize > 0: downscale and keep it
-  else: delete it after the request
+  delete it after the request
  • Remove maxCachedCloudImageSize and its fluent setter.
  • Transforms, the image editor, and indexing analysis still download originals when they need them, and clean them up afterward.
  • Remove the indexing "Cache remote images" option and the --cacheRemoteImages CLI option, with a migration that drops the session column.
  • The Yii adapter still accepts its legacy cache arguments, and ignores them.

Sites that set a positive size will download remote originals again for later transforms and image editing.

Remote image sources are now downloaded when a transform, image editor preview, or index analysis needs them, used, and cleaned up, rather than retained and downscaled. Remove the setting, its fluent setter, and the indexing cache-warming option, with a migration that drops the obsolete session column. The Yii adapter still accepts its legacy cache arguments, and ignores them.

Amp-Thread-ID: https://ampcode.com/threads/T-830d6cd5-57a8-4228-a4cd-3665cb1c7013
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

📚 Storybook previews

@craftcms/ui — open Storybook

No changed components detected in this Storybook.

resources/js — open Storybook

No changed components detected in this Storybook.

@timkelty
timkelty added this pull request to stack #20789 November 17, 2026 14:54
@timkelty
timkelty marked this pull request as ready for review November 17, 2026 14:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T15:01:09.509463Z 4785570 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4785570ae3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +189
app()->terminating(function () use ($imageSourcePath) {
File::delete($imageSourcePath);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Purge legacy downscaled sources before reusing them

On an upgrade where maxCachedCloudImageSize was positive, imageSourcePath can already contain the old downscaled cache. The freshness check above accepts that file when the remote modification time is unchanged, and this new callback deletes it only after it has been used. Consequently, the first newly requested transform can be generated by upscaling the cached copy rather than reading the original, and that degraded transform is then retained. Delete or otherwise invalidate legacy cached sources before they can be returned; the new previously cached test currently writes a full-size original and therefore does not exercise this upgrade case.

Useful? React with 👍 / 👎.

Comment on lines +187 to +189
app()->terminating(function () use ($imageSourcePath) {
File::delete($imageSourcePath);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clean remote sources after each queued transform

When GenerateImageTransform processes remote images through a normal long-running queue:work process, this callback does not run after each job; it waits until the Artisan process exits. Laravel explicitly documents that queue workers are long-lived and retain the booted application state. Because this change now stores full originals rather than size-limited copies, a worker processing many distinct remote assets can accumulate all of those files under the asset-sources directory and exhaust local storage before it restarts. Add per-job cleanup, such as a finally block or queue lifecycle listener, rather than relying solely on application termination.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but this isn't new in this PR. On 6.x with the default maxCachedCloudImageSize of 0, remote sources are already only deleted when the app terminates. Per-job cleanup is tracked in #20803.

A source cached while maxCachedCloudImageSize was positive may be a downscaled copy, which passed the freshness check, so the first transform after upgrading could upscale it.

Amp-Thread-ID: https://ampcode.com/threads/T-830d6cd5-57a8-4228-a4cd-3665cb1c7013
Co-authored-by: Amp <amp@ampcode.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant