Problem/Motivation
Currently there are a number of low-level file operations in file.inc. These are difficult to test, and have hidden and often circular dependencies. They should be moved to a service and cleaned up.
Proposed resolution
Move low-level file operations to the file_system service.
Remaining tasks
None
User interface changes
None.
API changes
Old functions in file.inc are deprecated, and all usages converted to using methods in the file_system service (\Drupal\Core\File\FileSystemInterface)
Data model changes
None.
Release notes snippet
See change record https://www.drupal.org/node/3006851
Original Summary
Problem/Motivation
file_unmanaged_copy() has an @todo saying@todo Replace drupal_set_message() calls with exceptions instead.
added a long time ago by #517814: File API Stream Wrapper Conversion
Proposed resolution
Introduces a new service, file_handler.unmanaged
, and an accompanying interface. This service has methods for file operations, e.g. copy()
, which does exactly what file_unmanaged_copy()
does, except it throws exceptions. file_unmanaged_copy()
becomes a deprecated wrapper around this method, and if it throws any exceptions, they will be caught and logged, and the function will return FALSE.
In other words, as far as calling code is concerned, file_unmanaged_copy()
will behave exactly the same way as it did before. Perfect backwards compatibility. Bam!
Remaining tasks
Refactor allfile_unmanaged_*
functions into thefile_handler.unmanaged
handler service.- Create
file_handler.managed
service that has the same public API and deprecate old managed file API. - Deprecate all remaining functions in
core/included/file.inc
in favor of filesystem service:file_munge_filename(), file_create_filename(), file_destination()
, etc.
User interface changes
None.
API changes
- Create new hander services with accompanying interfaces and exceptions.
- Deprecate all
file_unmanaged_*()
andfile_*()
functions.
Related Issues
- @todo was introduced by #517814: File API Stream Wrapper Conversion