Using Gutenberg Drupal 8.x-1.10 on Drupal 8.8.1, all files uploaded via the core/file block are listed as Temporary with 0 uses in Drupal’s file list. Consequently, they are automatically deleted after a while.
Uploading images with the core/image component, on the other hand, works fine. After saving, the image is marked as permanent.

Could this be a problem in our configuration? We’re not using a custom module here, just the default File component.

Here is a screenshot of the file list with the same file twice - once uploaded with core/image and once with core/file:
files list with temporary and permanent files

CommentFileSizeAuthor
#2 Screenshot_2020-01-15 Files Volt(2).png36.7 KBwmnnd

Comments

wmnnd created an issue. See original summary.

wmnnd’s picture

Issue summary: View changes
StatusFileSize
new36.7 KB
bgm’s picture

Hi, I have users who seem to be running into this bug from time to time. Their images disappear after some time. Although it does not seem to be systematic. Image attachments seem to work fine most of the time.

Is there something in user behaviour that could be causing it?

For example, I noticed that sometimes when users run into problems, they copy-paste the blog post into a new blog post, presumably without re-uploading the images. That would trigger a deletion, right?

szeidler’s picture

Thanks for the report.

This seems to be related to the g-media-attributes library. I added a pull request there to add the entity attributes to the markup, which will make Drupal set the files permanent, once the content is saved.

codebymikey’s picture

This should be addressed after the #3163200: Make Gutenberg entity-type-agnostic issue lands.

It already includes @szeidler's fixes https://git.drupalcode.org/project/gutenberg/-/blob/c28eeb29/js/media-at...

The g-media-attributes package was migrated into the module to make it immutable and it also makes it easier to address changes within D.O.

One thing to bear in mind with this change is whether a deprecated property is needed to migrate existing content or not.

codebymikey’s picture

codebymikey’s picture

Title: Uploads via core/file marked as temporary » Uploads via core/file and core/audio are marked as temporary
thorandre’s picture

Assigned: Unassigned » marcofernandes

Assigning to Marco.

He'll address the bug and fix this on the g-media-attributes package. Seems like codebymikey is on to something, so let's look into that.

szeidler’s picture

Version: 8.x-1.10 » 8.x-2.x-dev
Assigned: marcofernandes » szeidler
szeidler’s picture

Priority: Major » Normal

This problem seems to be mitigated by the media module. if you use Media in core, the uploaded file will be marked as being permanent, since it's related to the media entity.

Since not having media is rather an edge case, I'm lowering down the priority.

szeidler’s picture

Solving this seems to be a bit more challenging, although the priority is not that high anymore, knowing it will just not be a problem with enabled media in core.

The challenge is, that we would need to whitelist the HTML elements, to actually make the the required tags data-entity-type="file" data-entity-uuid="254b5724-fc89-4852-8c81-1d5855a4fc2b" appear in the markup. With those tags the Drupal core editor module will take care of the file tracking and mark the file as permanent.

It seems that changing the following line in https://github.com/front/g-media-attributes/blob/master/src/override.js#L47 would to the trick.

From:

  if(type === 'img' || type === 'video' || (props.style && props.style.backgroundImage)) {

to:

  if(type === 'img' || type === 'video' || type === 'audio' || (props.className && props.className.includes('wp-block-file__button')) || (props.style && props.style.backgroundImage)) {

You will see that this is far from being elegant, but seems to be the only working approach without bigger refactoring.

@marcofernandes: Regardless of my comments above. I also noticed that the merged in tag on the github repositrory didn't automatically got published on npmjs.com, which makes it not possible to directly update it with the update script in Gutenberg. See https://www.npmjs.com/package/@frontkom/g-media-attributes

marcofernandes’s picture

I'm having issues publishing to NPM. I'll check this ASAP.

marcofernandes’s picture

Status: Active » Fixed

@szeidler changed g-media-attributes as you suggested. Tested and files now move to permanent. Thanks!

Status: Fixed » Closed (fixed)

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