[wp-trac] [WordPress Trac] #55165: Site Logo Block causing division by zero notice when image dimensions are not available

WordPress Trac noreply at wordpress.org
Tue Feb 15 08:12:39 UTC 2022


#55165: Site Logo Block causing division by zero notice when image dimensions are
not available
--------------------------+-----------------------------
 Reporter:  maximus80     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  5.9
 Severity:  minor         |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 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:


 {{{#!php
 if ( empty( $attributes['width'] ) || empty( $image ) ) {
 }}}


 with

 {{{#!php
 if ( empty( $attributes['width'] ) || empty( $image ) || ! $image[1] || !
 $image[2] ) {
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55165>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list