Problem/Motivation

Changing and saving configuration, while having a custom logo uploaded in the Icon field, will break the logo. The logo will be removed.

Steps to reproduce

  • Upload an Icon and press save
  • Reload the settings page and change another setting, then save.
  • The icon will disappear and won't be used for the application anymore.

Proposed resolution

Fix the issue.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork pwa-3419797

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

Grevil created an issue. See original summary.

grevil’s picture

grevil’s picture

I can not directly reproduce the issue in my dev environment, but I get an error, that the uploaded file isn't referenced anywhere, which leads to not being able to save the configuration at all:

The file used in the Upload image field may not be referenced.

grevil’s picture

grevil’s picture

The provided MR fixes the issue, but the fake file usage feels filthy...

Unsure how to proceed from here. @Anybody, what do you suggest? The error triggers in line 443 of "/core/modules/file/src/Element/ManagedFile.php" and completely prevents the form submition, so we have to find a fix here.

grevil’s picture

Priority: Normal » Major

Ok, great now I can replicate the original issue in my dev environment.

Setting this to "Major", as not only the image preview will be removed, but furthermore the manifest.json won't be using the uploaded image anymore, but instead uses the fallback image provided with the module.

grevil’s picture

Assigned: Unassigned » anybody
Status: Active » Needs review

Fixed! The problem was, that $form_state->getValue('image_fid') returned an id string and $config->get('image_fid') a number, meaning this if case here:

    // If a new image is uploaded, we need to delete the old ones:
    if ($config->get('image_fid') !== $imageId) {
      $this->manifest->deleteImages();
    }

Always resulted in TRUE, deleting the images on each form submit. Please review!

grevil’s picture

anybody’s picture

Assigned: anybody » Unassigned
Status: Needs review » Reviewed & tested by the community
anybody’s picture

  • Grevil committed 9ea80b9f on 2.x
    Issue #3419797: Saving a configuration, while having a custom logo...
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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