Problem/Motivation

file_save_upload() uses a static $upload_cache to avoid reprocessing a file already moved from its temporary path when the form rebuilds within the same request. This is a function-local static keyed by field name, with no service boundary, and blocks an service replacement in #3619418: Add a service to replace file_save_upload() and deprecate it that needs the same protection. This issue is a step toward deprecating file_save_upload().

Steps to reproduce

Proposed resolution

Use the CacheBackendInterface memory.cache bin service for file uploads. file_save_upload() calls it via \Drupal::service(), keyed by field name, storing the results for a field after first processing. The proposed new multi-file upload service in #3619418: Add a service to replace file_save_upload() and deprecate it will inject the same service normally.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3619416

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Status: Active » Needs review
kim.pepper’s picture

Issue summary: View changes
kim.pepper’s picture

Issue summary: View changes
kim.pepper’s picture

Issue summary: View changes
kim.pepper’s picture

Title: Add a request-scoped memory cache for file uploads » Replace file_save_upload()'s static cache with the cache.memory bin
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

kim.pepper’s picture

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.