Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
#2830016: Add a thumbnail/icon field to Paragraphs type added an icon filed to Paragraphs Types. However, the files to be used as icons uploaded through the form element it adds (in admin/structure/paragraphs_type/{paragraphs_type}
) are temporary. (\Drupal\file\Entity\File::isTemporary
returns TRUE
for these files.) Thus, Drupal deletes the icons after a while.
Proposed resolution
Adjust ParagraphsType
to properly save the icon files as permanent. To achieve this add file usage registration and deregistration through the file.usage
service as appropriate.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#28 | paragraphs_type_icons-2870989-28.patch | 7.06 KB | VladimirMarko |
#23 | interdiff-2870989-18-23.txt | 683 bytes | VladimirMarko |
#23 | paragraphs_type_icons-2870989-23-test-only.patch | 4.28 KB | VladimirMarko |
Comments
Comment #2
VladimirMarko CreditAttribution: VladimirMarko commentedComment #3
VladimirMarko CreditAttribution: VladimirMarko commentedComment #4
VladimirMarko CreditAttribution: VladimirMarko commentedComment #8
VladimirMarko CreditAttribution: VladimirMarko commentedAdded the
file
module to the failing kernel tests.Comment #11
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedNo need for new variable here, just use $this->icon_uuid
You could add an assertion for the permanent status here.
Same for this, no need for this new variable, it is only used once.
This should be moved outside, it is nested in the opposite if statement(!update).
Or better, you can remove it and just leave the delete usage of the old icon inside the opposite if statement(!update).
After you make the previous change, you will have to check if isset($this->original) here. Because when creating a new paragraph type, there is no original and this displays warning message.
Comment #12
VladimirMarko CreditAttribution: VladimirMarko commentedI discussed this further with @Ginovski. We agreed that 4 and 5 are not necessary.
I implemented the other changes.
Comment #13
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedRTBC +1
Comment #16
VladimirMarko CreditAttribution: VladimirMarko commentedComment #17
Berdirfile_entity is an optional contrib module. We don't want to type hint on that but FileInterface in core. Also, as discussed, $uuid shouldn't be allowed to be NULL and should never becalled as NULL in the patch. Update the type and remove the if () check.
Comment #18
VladimirMarko CreditAttribution: VladimirMarko commentedImplemented the changes.
Comment #21
Berdir$files_array is a bit uncommon, usually we just use $files or so, but fine.
Comment #23
VladimirMarko CreditAttribution: VladimirMarko commentedChanged
$file_array
to$files
.Comment #27
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedIt seems that this needs a re-roll :/
Comment #28
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commentedRe-roll.
Comment #30
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedCommitted, thanks.