Problem/Motivation

As part of #3221796: [META] Modernise file upload logic we identified that file locking occurs in 3 places:

  • \Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader
  • \Drupal\file\Plugin\rest\resource\FileUploadResource
  • \Drupal\ckeditor5\Controller\CKEditor5ImageController

However, it doesn't occur in file_save_upload() which is currently the only code using FileUploadHandler.

Steps to reproduce

Proposed resolution

Add lock support to FileUploadHandler to make migrating those other services over easier.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3389016

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

Title: Move file upload lock handling to FileUploadHandler » Add file upload lock handling to FileUploadHandler
Status: Active » Needs review

Changed title from 'move' to 'add' since we aren't moving in this issue.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record updates

Change looks good and is all green. The CR could use some updates though.

Thanks!

kim.pepper’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record updates

Updated change record

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

xjm made their first commit to this issue’s fork.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

I'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions.

But this needs to be rebased.

kim.pepper’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Re-rolled. Back to RTBC

kim.pepper’s picture

Title: Add file upload lock handling to FileUploadHandler » [PP-1] Add file upload lock handling to FileUploadHandler
Status: Reviewed & tested by the community » Postponed

I think we should postpone this on #3388985: Make CKEditor5ImageController reuse FileUploadHandler so we have an example of moving the locking rather just adding it as we do here.

larowlan’s picture

Title: [PP-1] Add file upload lock handling to FileUploadHandler » Add file upload lock handling to FileUploadHandler
Status: Postponed » Active

Blocker is in

kim.pepper’s picture

Status: Active » Needs review

Rebased on 11.x

smustgrave’s picture

Status: Needs review » Needs work

Seems to have failing tests, reran but still failed.

kim.pepper’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

That seemed to be it!

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Left some comments on the MR

kim.pepper’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback appears to be addressed.

bkline’s picture

@trigger_error('Calling ' . __METHOD__ . '() without the $lock argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3389017', E_USER_DEPRECATED);

I don't think this deprecation message means what it says, which is that calls to the FileUploadHandler constructor will be required to omit the $lock argument in drupal:11.0.0. There are a number of spots like this in the patch.

Perhaps you meant "prohibited" or "prevented" where you have "required"?

kim.pepper’s picture

#19 No it's correct as it is. We are adding a new $lock dependency, which will throw a deprecation warning if it's not provided in 10.3.0, and as a BC layer, we look up the service using \Drupal::service(). But in Drupal 11.0.0 we remove this BC layer and it will throw an error if it's not provided.

bkline’s picture

@kim.pepper Your description in #20 matches what I assumed you meant the deprecation message to convey, but that's not what it actually says. If you read its language carefully, you'll realize that "Calling" is the subject of both verbs, so parsed correctly, the meaning is as follows:

"Calling __construct() without the $lock argument is deprecated in drupal:10.3.0."

and

"Calling __construct() without the $lock argument is required in drupal:11.0.0."

kim.pepper’s picture

'Calling ' . __METHOD__ . '() without the $lock argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0' is correct.

bkline’s picture

Sigh. Oh, well, at least they're just deprecation messages, so they be gone eventually, along with the incorrect wording. 🙄

kim.pepper’s picture

Feel free to open a [Policy, No Patch] issue to suggest changes to the wording. We have a phpcs rule to ensure it matches the official pattern. See https://www.drupal.org/about/core/policies/core-change-policies/drupal-d...

alexpott’s picture

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

This is a nice improvement to the API.

Committed and pushed 6236d36180 to 11.x and e44ea05058 to 10.3.x. Thanks!

  • alexpott committed e44ea050 on 10.3.x
    Issue #3389016 by kim.pepper, xjm, larowlan: Add file upload lock...

  • alexpott committed 6236d361 on 11.x
    Issue #3389016 by kim.pepper, xjm, larowlan: Add file upload lock...

Status: Fixed » Closed (fixed)

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