Closed (outdated)
Project:
Drupal core
Version:
8.7.x-dev
Component:
file system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Dec 2018 at 04:12 UTC
Updated:
27 Feb 2019 at 00:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kim.pepperInitial attempt...
Comment #4
kim.pepperFix test fail.
Comment #5
kim.pepperInject the file_upload service where possible.
Comment #6
kim.pepperCreate a change record and update links.
Comment #9
kim.pepperFix fails.
Comment #10
andypostIt brings state to service, maybe better to keep factory here?
This both methods looks more like static functions, the second one is more related to php ini settings then file upload
Maybe better to extract it to Php or Requirements class like #2908079: Move some of the bootstrap.inc PHP-related constants to \Drupal and deprecate the old versions
Comment #11
andypostComment #12
seanrShould reference unmungeFilename, right?
Comment #13
kim.pepperRe: #10
Re #12
Comment #14
wim leersThis is massively overlapping with #2940383: [META] Unify file upload logic of REST and JSON:API! Please continue working on that issue instead. That already has 2 proven consumers: the core REST module and the contrib-soon-core JSON:API module. Having that same service be used by everything else doing file uploads in core would be a huge win, not the least in terms of security hardening!
Comment #15
andypostAs I see it makes sense to split tasks - file uploader service in related issue use much more dependencies in constructor, guts tells it needs factoring
Comment #16
kim.pepperYeah, this is perhaps file upload utilities(?). So far, we have (un)mungeFilename() and getUploadMaxSize(). These could be static methods, apart from a config check for 'allow_insecure_uploads' which just short-cuts the entire logic of mungeFilename() and returns the original. And also logging.
Comment #17
wim leersIf this service is ever going to be used in HTTP APIs, then this cannot be injected. Instead, an exception needs to be thrown that the caller needs to convert into calls to the messenger service. The caller knows whether we're operating in a HTML or API context.
These methods indeed are only helpers for file uploads, they don't do actual file uploads. The third method also seems pretty unrelated to the other two.
Either this service needs to become more capable so that its name matches its capabilities, or it needs to be renamed.
I think the first two methods could be on a
UploadedFileNameMungerservice.🎉
Is having an interface for this really necessary? What's the use case for overriding these? I think only a single concrete implementation is sufficient for now.
Comment #18
wim leersApparently no more reviews are coming in, so marking NW.
Comment #19
wim leersAnother issue impacted by this: #2492171-230: Provide options to sanitize filenames (transliterate, lowercase, replace whitespace, etc).
Comment #20
dwwYeah, what about file.module and
_file_save_upload_single()itself? Should that be considered in scope for this effort, or do we want to handle that separately? It's a function I find myself way too familiar with after slogging it out in #2492171: Provide options to sanitize filenames (transliterate, lowercase, replace whitespace, etc) (thanks, @Wim, for already marking that related).Comment #21
dww#997900: Not possible to allow uploading files with any file extension is another one that overlaps/conflicts with this.
Comment #22
jibranComment #23
berdirRe: #14. Currently there is almost zero overlapping between the patch here and your issue, biggest overlap is possibly the name but that's in flux anyway.
However, there so seem to be a real large overlap with #3032390: Add an event to sanitize filenames during upload which completely replaces the munge/unmunge functions and makes the whole thing an implementation detail instead of an API.
With that, the only thing that's left here is one tiny API function that has zero dependencies: file_upload_max_size(), I proposed in another issue recently that drupal_set_time_limit() could be added to that as well and possibly this max upload thing could do there as well?
Comment #24
kim.pepper@Berdir Sound like a reasonable idea. Can you link to the other issue?
Comment #25
andypost@kim.pepper It's linked already #3000057-13: Deprecate drupal_set_time_limit() and file_upload_max_size() and move to Environment component
Comment #26
kim.pepperI have moved the file_upload_max_size() deprecation to #3000057: Deprecate drupal_set_time_limit() and file_upload_max_size() and move to Environment component
Comment #27
dwwmunge/unmunge is being completely refactored at #3032390: Add an event to sanitize filenames during upload
file_upload_max_size() now RTBC @ #3000057: Deprecate drupal_set_time_limit() and file_upload_max_size() and move to Environment component
I think "outdated" is the right status in here now, since everything is now handled elsewhere.
Thanks,
-Derek