Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#55165 closed defect (bug) (reported-upstream)

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

Reported by: maximus80's profile maximus80 Owned by: audrasjb's profile audrasjb
Milestone: Priority: normal
Severity: normal Version: 5.9
Component: Editor Keywords:
Focuses: Cc:

Description

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] ) {

Attachments (2)

site-logo.php (5.7 KB) - added by maximus80 3 years ago.
Patched site-logo.php
55165.diff (646 bytes) - added by maximus80 3 years ago.

Download all attachments as: .zip

Change History (8)

@maximus80
3 years ago

Patched site-logo.php

@maximus80
3 years ago

#1 @maximus80
3 years ago

  • Keywords has-patch added; needs-patch removed

#2 @audrasjb
3 years ago

  • Milestone changed from Awaiting Review to 5.9.1
  • Owner set to audrasjb
  • Severity changed from minor to normal
  • Status changed from new to accepted

Thanks for the report @maximus80!
This need to be reported upstream on Gutenberg GitHub repository. I opened an issue and added a PR for this change:

Let's keep this ticket open for now to make sure it's addressed.

#3 @maximus80
3 years ago

Ah ok wasn't sure about that, as it is already in core, but good to know.

#4 @hellofromTonya
3 years ago

  • Keywords has-patch removed
  • Milestone changed from 5.9.1 to 5.9.2

5.9.1. is happening in a few hours. Since the issue is still open and unresolved, moving this ticket to 5.9.2.

Also resetting keywords as fix will happen in Gutenberg and then be backported to Core.

#5 @hellofromTonya
3 years ago

  • Milestone changed from 5.9.2 to 5.9.1

Whoops, wrong ticket. Sorry about that. Reverting back to 5.9.1. The fix will be included in the backported changes.

#6 @hellofromTonya
3 years ago

  • Milestone 5.9.1 deleted
  • Resolution set to reported-upstream
  • Status changed from accepted to closed

Fix was included in [52765] #55179. Closing as fixed upstream.

Note: See TracTickets for help on using tickets.