[wp-trac] [WordPress Trac] #54943: PHP Warnings in image_get_intermediate_size() on PHP >= 8

WordPress Trac noreply at wordpress.org
Mon Aug 7 19:11:08 UTC 2023


#54943: PHP Warnings in image_get_intermediate_size() on PHP >= 8
-------------------------------------------------+-------------------------
 Reporter:  fhwebdesign                          |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Media                                |     Version:  5.9
 Severity:  normal                               |  Resolution:
 Keywords:  php80 has-patch reporter-feedback    |     Focuses:
  needs-testing-info needs-unit-tests changes-   |
  requested                                      |
-------------------------------------------------+-------------------------

Comment (by hellofromTonya):

 Adding historical / contextual references:

 During 2.5.0, function `image_get_intermediate_size()`:
 * was added in changeset [7135].
 * The `foreach` iteration over the `$imagedata['sizes']` was added in
 changeset [7263], which expected the size data to be an array:
 {{{#!php
 foreach ( $imagedata['sizes'] as $_size => $data ) {
     if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) ||
 ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
 }}}

 The code where the warning / notice is thrown has expected an `array` of
 for each size since WP 2.5.0. This code has never had defensive checks to
 ensure `$data` is an array before it checks `$data['width']`.

 Thus, I think the root cause is not in `image_get_intermediate_size()`,
 but elsewhere.

 I'm also wondering if the problem was not introduced in 5.9.0 ???

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54943#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list