Problem/Motivation

There is a @todo in the documentation of file_save_upload() which says:

@todo: move this logic to a service in https://www.drupal.org/node/2244513.

However, this function calls _file_save_upload_single(), which uses the file_system service. Moreover, this function seems perfectly fine according to #3101976: Add tests for file_save_upload trimming trailing . characters from filenames and move the test into SaveUploadTest.

Proposed resolution

This note is confusing since it suggests there is a better way than using this function, and thus it should be removed.

Remaining tasks

  1. Acknowledge whether this note is no longer relevant.
  2. If so, remove it (see attached patch).

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

FMB created an issue. See original summary.

fmb’s picture

Status: Active » Needs review
StatusFileSize
new663 bytes
fmb’s picture

Issue summary: View changes
joachim’s picture

Status: Needs review » Needs work

It makes sense to me that this code should be moved to a service.

But #2244513: Move the unmanaged file APIs to the file_system service (file.inc) is about file.inc, which this function isn't in -- it says "Currently there are a number of low-level file operations in file.inc ..."

So the TODO should probably stay, but either:

a. find the right existing issue it should mention
b. create an issue if there isn't one already

and then update the TODO to reference that instead.

kim.pepper’s picture

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

liam morland’s picture

Title: TODO note for file_save_upload() might no longer be relevant » @todo for file_save_upload() might no longer be relevant
Version: 9.5.x-dev » 11.x-dev
Issue summary: View changes
Parent issue: » #2244513: Move the unmanaged file APIs to the file_system service (file.inc)
Related issues: +#3232248: Move _file_save_upload_single to a service and deprecate, +#2940383: [META] Unify file upload logic of REST and JSON:API
liam morland’s picture

Status: Needs work » Needs review
StatusFileSize
new692 bytes

This updates the @todo to point to this issue. Once this is committed, this issue can be changed to be about creating the service.

smustgrave’s picture

Status: Needs review » Needs work

Not sure I see the benefit of updating a comment that this issue will be worked on, and working on it later.

But if we are just trying to update to a more relevant issue then a follow up should be opened to actually fix it and the comment pointed there.

liam morland’s picture

Status: Needs work » Needs review
StatusFileSize
new692 bytes

I have created #3370626: Convert file_save_upload() to a service. This patch points to that issue.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

Thanks!

liam morland’s picture

Title: @todo for file_save_upload() might no longer be relevant » Make @todo for file_save_upload() refer to the correct issue
catch’s picture

Status: Reviewed & tested by the community » Needs work

I think we should just remove the @todo altogether.

liam morland’s picture

Status: Needs work » Needs review
StatusFileSize
new663 bytes

I'm OK with that, though having the @todo could save some time. A person sees this function, thinks it should be a service, and opens a ticket or do they see the @todo and visit the existing ticket? The cost of having the @todo is zero and there is a benefit.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Don't think I need the tests to finish to know this won't break anything.

  • catch committed d5491b76 on 10.1.x
    Issue #3178225 by Liam Morland, FMB, smustgrave, joachim: Make @todo for...

  • catch committed b6b1fb1e on 11.x
    Issue #3178225 by Liam Morland, FMB, smustgrave, joachim: Make @todo for...
catch’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

I think the fact this issue is open with six people on it shows there was a cost to having the @todo. I think they're useful when an implementation has drawbacks but needs a stack of issues to improve, but not for saying procedural code should be OOP.

Committed/pushed to 11.x and cherry-picked to 10.1.x, thanks!

liam morland’s picture

Title: Make @todo for file_save_upload() refer to the correct issue » Remove @todo from file_save_upload()

Adjusting title to match the work that was actually done.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.