Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Logo Block causing division by zero notice when image dimensions are not available #38807

Closed
audrasjb opened this issue Feb 15, 2022 · 1 comment · Fixed by #38808
Closed
Labels
[Block] Site Logo Affects the Site Logo Block [Type] Bug An existing feature does not function as intended

Comments

@audrasjb
Copy link
Contributor

Description

Please note that this is a report coming from Trac, and that maximus80 deserves the props here.

Copy-paste from Trac:

Notice is
Warning: Division by zero in wp-includes/blocks/site-logo.php on line 21

This will happen when the dimensions of the image used inside the site logo block can't be retrieved for some reason.

Example: SVG image being used. That will lead to the divisors being zero here: https://core.trac.wordpress.org/browser/branches/5.9/src/wp-includes/blocks/site-logo.php#L20

Easiest way to fix would be to replace line 17:
if ( empty( $attributes['width'] ) || empty( $image ) ) { with
if ( empty( $attributes['width'] ) || empty( $image ) || ! $image[1] || ! $image[2] ) {

Step-by-step reproduction instructions

  1. Install a plugin to make sure you can upload SVGs to your website
  2. Add a Site logo block
  3. Use the SVGs
  4. See the notice thrown by the block server-side rendering

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 5.9
  • Random plugin to allow SVG uploads

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added [Block] Site Logo Affects the Site Logo Block [Type] Bug An existing feature does not function as intended labels Feb 15, 2022
@audrasjb audrasjb linked a pull request Feb 15, 2022 that will close this issue
8 tasks
@maximus80
Copy link

Thanks for porting this over here @audrasjb 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Site Logo Affects the Site Logo Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants