Problem/Motivation

When an SDC component is assigned to a File or Image field formatter within an entity view mode, Drupal generates a dummy sample file in the managed files system (file_managed table). While sample files generated for Image fields are marked as temporary, those generated for File fields are created as permanent files. Furthermore, whenever the same field is reused in another content type, an additional dummy file is automatically generated.

In addition, if the field is an Image field configured to only allow .svg extensions (for example, when using the svg_image module), generating dummy content causes a fatal error and breaks the site completely, as the default dummy file generation mechanism fails to handle SVG files properly.

Steps to reproduce

  1. Enable the ui_patterns_field_formatters module.
  2. Create a content type and add a File or Image field to it.
  3. Navigate to the entity's Manage Display view mode settings and set the field to render using any SDC component.
  4. Go to Admin > Content > Files (/admin/content/files) and observe that sample file entries have been created in the managed files directory.
  5. Create a second content type and reuse the existing File/Image field. Check the files list again to observe that additional sample files have been generated.

Proposed resolution

In ui_patterns_field_formatters/src/Plugin/Field/FieldFormatter/FormatterBase.php, the getComponentSourceContexts() method generates sample field content when no entity instance exists. Update this logic to prevent auto-generating dummy sample files in the managed files system during component context resolution.

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

cbccharlie created an issue. See original summary.

cbccharlie changed the visibility of the branch 3623890-sdc-field-formatter to hidden.

cbccharlie changed the visibility of the branch 3623890-sdc-field-formatter to active.

cbccharlie’s picture

Status: Active » Needs review
just_like_good_vibes’s picture