- Issue created by @kim.pepper
- Merge request !4876Issue #3389688: Provide a trait to get file upload location from field settings โ (Closed) created by kim.pepper
- last update
over 1 year ago 30,363 pass - Status changed to Needs review
over 1 year ago 2:38am 26 September 2023 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Looks like it's going to be problematic replacing the code in method
\Drupal\file\Plugin\Field\FieldType\FileItem::doGetUploadLocation()
with a trait because it is static. - Status changed to Needs work
over 1 year ago 6:20pm 26 September 2023 - Status changed to Needs review
about 1 year ago 11:43pm 4 December 2023 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Fixed merge conflicts and added a change record.
- Status changed to Needs work
about 1 year ago 11:53pm 5 December 2023 - Status changed to Needs review
about 1 year ago 12:55am 6 December 2023 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Merged with 11.x
- ๐ฎ๐ณIndia prashant.c Dharamshala
The trait seem to be functioning well for the file fields. I was considering whether it might be sensible to maintain consistency in the function names within the trait as well. For instance, changing
getFileUploadLocation
togetUploadLocation()
. Just a suggestion. - Status changed to RTBC
about 1 year ago 2:26pm 6 December 2023 - last update
about 1 year ago 30,696 pass - last update
about 1 year ago 30,697 pass - last update
about 1 year ago 30,698 pass - last update
about 1 year ago 30,712 pass - last update
about 1 year ago 30,726 pass - last update
about 1 year ago 30,766 pass - last update
about 1 year ago 25,900 pass, 1,816 fail - last update
about 1 year ago 25,882 pass, 1,823 fail - last update
about 1 year ago CI aborted - last update
about 1 year ago 25,905 pass, 1,832 fail 8:17 3:38 Running- Status changed to Needs work
about 1 year ago 2:24am 28 December 2023 - ๐ณ๐ฟNew Zealand quietone
I'm triaging RTBC issues โ . I read the IS, the comments, the change record and the MR. I do like a bit of tidying up!
The question raised in #9 has not been answered. Why the name change? And how will this effect any contrib usages of
getUploadLocation
?The change record also needs to be updated, it is referring to changes that have not been made. Also, the first sentence is difficult to read, and English is my first language. Also, instead of mentioning a usage in a contrib project it would be more helpful to explain what must be done in contrib to update modules for this change, such as a before and after example.
Setting to needs work for the above.
- Status changed to Needs review
about 1 year ago 12:20am 29 December 2023 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
- Rebased on 11.x
- Renamed to
getUploadLocation()
as per the suggestion in #9 - Updated the IS and CR
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
I really wanted to replace
\Drupal\file\Plugin\Field\FieldType\FileItem::getUploadLocation()
with the trait but not sure how to work around deprecating a static method with a class method. - ๐บ๐ธUnited States smustgrave
thoughts on handling that replacement in a follow up?
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Created follow-up ๐ [PP-1] Replace FileItem::getUploadLocation() with FileUploadLocationTrait Active
- ๐บ๐ธUnited States smustgrave
Oh cool. Then in that case rest seems fine to me.
- Status changed to RTBC
about 1 year ago 2:08pm 2 January 2024 - last update
about 1 year ago 25,909 pass, 1,828 fail - last update
about 1 year ago 25,910 pass, 1,829 fail - last update
about 1 year ago 25,993 pass, 1,821 fail - last update
about 1 year ago 25,963 pass, 1,817 fail - Status changed to Needs review
about 1 year ago 10:45pm 15 January 2024 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
I thought I would have a go at replacing
FileItem::doGetUploadLocation()
with the trait method.Unfortunately,
generateSampleValue()
calls it and is a static method, so we have to call the trait method statically too. I added a@phpstan-ignore-next-line
but I'm not sure what the alternative is? - Status changed to Needs work
about 1 year ago 12:47am 18 January 2024 The Needs Review Queue Bot โ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide โ to find step-by-step guides for working with issues.
- Status changed to Needs review
about 1 year ago 1:17am 22 January 2024 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Updated IS
- Status changed to RTBC
about 1 year ago 3:18pm 24 January 2024 - ๐บ๐ธUnited States smustgrave
Reviewed the deprecation and link to CR appears correct https://www.drupal.org/node/3406099 โ
Reviewing actual CR and all the details are there.
Believe this is good.
- ๐ณ๐ฟNew Zealand quietone
This is my second visit here for triage. I didn't find any unanswered questions or other work to do.
Leaving at RTBC;
- Status changed to Needs review
11 months ago 9:42am 4 March 2024 - ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
I wonder if we don't have to add the service. Can we use the same approach as \Drupal\media_library\Form\FileUploadForm::createMediaFromValue and create a FileItem to do this.
Otherwise if we're going to go with the current approach I think we should be accepting a field definition object instead of settings and validating that it is a fiie item that we're generating a location for. Otherwise it's all a bit mushing random arrays together.
- Status changed to Needs work
11 months ago 10:07am 4 March 2024 The Needs Review Queue Bot โ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide โ to find step-by-step guides for working with issues.
- Status changed to Needs review
11 months ago 12:29am 5 March 2024 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
#23 @alexpott I'd prefer to use a service, as we depend on
'token'
and that has about 5 other dependencies.I've changed
\Drupal\file\Upload\UploadDestinationResolver::getUploadDestination()
from acceptingarray $settings
toFieldDefinitionInterface
and I think that works better. - ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
I've looked at both this and \Drupal\file\Validation\FileValidatorSettingsTrait::getFileUploadValidators() and I think that they both should be / have been part of the file field API. If we put them on \Drupal\file\Plugin\Field\FieldType\FileFieldItemList then we'd be able to call this methods from the field definition we already have.
I don't think our API should be decided by the fact that our field system struggles with container injection (only because it was updated before the container was truly available in the D8 cycle). Both getFileUploadValidators() and getUploadDestination() are extremely intimate to the internals of the file field type.
- Status changed to Needs work
11 months ago 2:31am 5 March 2024 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
#26 hmm, not sure exactly how that would work ๐ค
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
@alexpott re: #26 I added the method to
\Drupal\file\Plugin\Field\FieldType\FileFieldItemList::getUploadLocation()
but not sure how to access that from a$field_definition
. - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
@alexpott thanks for the review, but we still need to work out how to do this. See #28
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Yeah having this on the field item list doesn't work out :( I can't see how to get back to the list item either...
$field_definition->getClass()
returns\Drupal\file\Plugin\Field\FieldType\FileFieldItemList
but $field_defintion is actually a FieldItemDataDefinition.How about not deprecating the stuff on the FileItem and use that - as suggested in #23.
- Status changed to Needs review
10 months ago 2:22am 16 April 2024 - ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
I took the approach suggested in #30 of creating a file item from the field definition. I put it in a trait so it could get used by both REST and JSON API.
@alexpott Do we still want to postpone the deprecation to 12.x? It seems much less disruptive now.
- ๐ฆ๐บAustralia kim.pepper ๐โโ๏ธ๐ฆ๐บSydney, Australia
Updated title and IS
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Given they are both controllers I think 11.x is fine
- Status changed to RTBC
10 months ago 1:57pm 16 April 2024 - ๐บ๐ธUnited States smustgrave
Appears feedback has been addressed.
CR still appears fine, not sure if it was updated or mention removed in 12 before.
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Committed and pushed 7a12710863 to 11.x and e9c7c01bc8 to 10.3.x. Thanks!
-
alexpott โ
committed e9c7c01b on 10.3.x
Issue #3389688 by kim.pepper, smustgrave, alexpott, quietone: Add a...
-
alexpott โ
committed e9c7c01b on 10.3.x
- Status changed to Fixed
10 months ago 11:38pm 16 April 2024 -
alexpott โ
committed 7a127108 on 11.x
Issue #3389688 by kim.pepper, smustgrave, alexpott, quietone: Add a...
-
alexpott โ
committed 7a127108 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.