Problem/Motivation

When saving pwa config, with "Use the theme image" it shows this warning.
Warning: getimagesize(/var/www/html/webthemes/custom/paltana/logo.png): Failed to open stream: No such file or directory in Drupal\pwa\Form\ManifestConfigurationForm->submitForm() (line 370 of modules/contrib/pwa/src/Form/ManifestConfigurationForm.php).

It needs a "/" between the current directory and theme image:

We need to change this:

      $image_size = getimagesize(getcwd() . $theme_image);

to this:

      $image_size = getimagesize(getcwd() . '/' . $theme_image);

Steps to reproduce

Go to /admin/config/services/pwa/manifest
check on Use the theme image
Save

Proposed resolution

Apply the attached patch

Issue fork pwa-3323325

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

Carlitus created an issue. See original summary.

Akhil Babu made their first commit to this issue’s fork.

akhil babu’s picture

Thanks for the patch @Carlitus. When I checked this, 'Use the theme image' option was not working for me.theme_get_setting('logo.path', $nameOfDefaultTheme); was not returing the path to theme's logo. I have updated this to
theme_get_setting('logo.url', $nameOfDefaultTheme); and its working after that. Also, we can continue to use getcwd() . $theme_image to get the full url of the image.

I found one more issue in calculating image size. The current code is

      $image_size = getimagesize(getcwd() . $theme_image);
      if ($image_size[0] == $image_size[1]) {
        $this->messenger()
          ->addWarning($this->t('The theme image is not a square, your application image maybe altered (recommended size: 512x512).'));
      }

If $image_size[0] == $image_size[1], then the image will be square. Condition should be $image_size[0] != $image_size[1]. Corrected that also.

akhil babu’s picture

Status: Active » Needs review
deepalij’s picture

StatusFileSize
new167.57 KB

Tried to reproduce the issue stated in the IS.
Did not receive such a message when tried to save pwa config, with "Use the theme image".
Couldn't reproduce.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the MR! Fix looks correct!

  • Anybody committed cefefd51 on 8.x-1.x authored by Akhil Babu
    Issue #3323325 by Carlitus, Anybody: Warning: getimagesize. Doesn't work...
anybody’s picture

Clear fix, thank you @Akhil Babu!

anybody’s picture

Status: Reviewed & tested by the community » Fixed

  • Anybody committed c74269eb on cherry-pick-cefefd51 authored by Akhil Babu
    Issue #3323325 by Carlitus, Anybody: Warning: getimagesize. Doesn't work...

  • Anybody committed e260d13b on 2.x
    Issue #3323325 by Carlitus, Anybody: Warning: getimagesize. Doesn't work...

  • Anybody committed e260d13b on cherry-pick-d014ab6b
    Issue #3323325 by Carlitus, Anybody: Warning: getimagesize. Doesn't work...

  • Anybody committed e260d13b on cherry-pick-e8180d4b
    Issue #3323325 by Carlitus, Anybody: Warning: getimagesize. Doesn't work...

Status: Fixed » Closed (fixed)

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