Skip to content

[5.x] Avoid eager loading asset move folders#14694

Draft
el-schneider wants to merge 1 commit into
statamic:5.xfrom
el-schneider:fix/asset-move-folder-options
Draft

[5.x] Avoid eager loading asset move folders#14694
el-schneider wants to merge 1 commit into
statamic:5.xfrom
el-schneider:fix/asset-move-folder-options

Conversation

@el-schneider
Copy link
Copy Markdown
Contributor

@el-schneider el-schneider commented May 20, 2026

Summary

Fix asset browser move actions so destination folders are no longer serialized into every asset/folder action payload, as it renders our current setup with ~1000 folders basically unusable, due to ginormous payloads.

Previously, MoveAsset and MoveAssetFolder built a plain select field with every folder in the container as inline options. In large containers, the browser payload scaled with:

visible assets/folders × total folders in container

This PR reuses Statamic's existing asset_folder relationship field instead. The move actions now return a small field config:

  • type: asset_folder
  • container: <current container>
  • mode: select
  • max_items: 1

The initial asset browser payload stays small, and destination folders are loaded only when the Move modal opens.

Why reuse asset_folder?

Statamic already has a fieldtype for selecting folders from an asset container. It is relationship-backed and already loads selectable items through the relationship endpoint.

Reusing it avoids a new action-specific endpoint or custom UI while keeping the old dropdown-style UX. max_items: 1 also preserves the existing action value shape because the relationship field processes the selection back to a single folder path string.

Implementation notes

MoveAsset and MoveAssetFolder no longer call:

AssetContainer::find($this->context['container'])->assetFolders()

inside fieldItems().

AssetFolderFieldtype.vue now passes action config like container and mode through to the underlying relationship field. It also supports action modal usage where there is no publish storeName, by reading the container directly from field config.

Performance impact

Before:

  • every visible move action included every destination folder option
  • Blink::once() avoided repeated PHP computation, but not repeated JSON serialization

After:

  • browser response contains only lightweight field config
  • opening a Move modal performs one relationship request to load folder destinations

Copy link
Copy Markdown
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

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

We're only releasing security fixes for v5 now. Please target 6.x.

@jasonvarga jasonvarga marked this pull request as draft May 20, 2026 14:14
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.

2 participants