Problem/Motivation
In #3123832: [META] Fix @todo items referencing closed issues we discovered that there's a @todo
in \Drupal\file\Upload\FileUploadHandler::loadByUri
which references a d.o. issue that is already closed; #3223209: deprecate file_save_data, file_copy and file_move and replace with a service
Here's the @todo
:
/**
* Loads the first File entity found with the specified URI.
*
* @param string $uri
* The file URI.
*
* @return \Drupal\file\FileInterface|null
* The first file with the matched URI if found, NULL otherwise.
*
* @todo replace with https://www.drupal.org/project/drupal/issues/3223209
*/
protected function loadByUri(string $uri): ?FileInterface {
Steps to reproduce
Proposed resolution
The current code in \Drupal\file\Upload\FileUploadHandler::loadByUri
is almost similar to code that was changed here.
Let's apply the same changes to \Drupal\file\Upload\FileUploadHandler::loadByUri
to keep consistent.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3337162
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
Comment #2
SpokjeComment #4
SpokjeComment #5
smustgrave CreditAttribution: smustgrave at Mobomo commentedChange looks good and doesn't cause any issues so seems like a valid cleanup/update.
Comment #6
alexpottAdded review to MR - we need to use dependency injection here.
Comment #8
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedComment #9
smustgrave CreditAttribution: smustgrave at Mobomo commentedNow that the service has a new parameter it will need a change record.
Also new parameter should default to NULL and throw a trigger_error
Comment #10
paulocsdon't we need to deprecate it first as we are changing the service constructor params?
@deprecated in drupal:10.1.0 and is removed from drupal:11.0.0.
Comment #11
smustgrave CreditAttribution: smustgrave at Mobomo commentedSo this is adding a parameter so would need something like
With the URL being to the change record created here.
Then the test is maybe a Kernel test that shows you get that trigger_error when passing nothing in that last parameter spot.
Comment #13
paulocsOh yes. I have read 'thrown error' instead of 'trigger_error' :)
I have created the deprecation notice. I have also created a new branch and MR as I can not change the target branch of MR !3316.
Comment #15
smustgrave CreditAttribution: smustgrave at Mobomo commentedLooks good!
Comment #17
catchMade this change on commit, otherwise looks great.
Committed 283d9be and pushed to 10.1.x. Thanks!
Comment #20
quietone CreditAttribution: quietone at PreviousNext commentedPublished the CR