[wp-trac] [WordPress Trac] #59573: warning: trying to access array offset on value of type bool in wp-includes/media.php (was: warning: trying to access array offset on value of type bool in wp-incloudes/media.php)

WordPress Trac noreply at wordpress.org
Thu Oct 26 17:04:39 UTC 2023


#59573: warning: trying to access array offset on value of type bool in wp-
includes/media.php
----------------------------+------------------------------
 Reporter:  androidforlife  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Media           |     Version:  6.3.1
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------
Changes (by sabernhardt):

 * component:  General => Media


Old description:

> function image_get_intermediate_size($post_id, $size = 'thumbnail')
> {
>     $imagedata = wp_get_attachment_metadata($post_id);
>
>     // Überprüfung, ob $imagedata und $imagedata['sizes'] echte Arrays
> sind
>     if (!is_array($imagedata) || empty($imagedata['sizes']) ||
> !is_array($imagedata['sizes'])) {
>         return false;
>     }
>
>     // Überprüfung, ob $size eine gültige Struktur hat
>     if (!is_array($size) || count($size) < 2) {
>         return false;
>     }
>
>     $data = [];
> .....

New description:

 {{{
 function image_get_intermediate_size($post_id, $size = 'thumbnail')
 {
     $imagedata = wp_get_attachment_metadata($post_id);

     // Checking whether $imagedata and $imagedata['sizes'] are real
 arrays.
     if (!is_array($imagedata) || empty($imagedata['sizes']) ||
 !is_array($imagedata['sizes'])) {
         return false;
     }

     // Checking whether $size has a valid structure.
     if (!is_array($size) || count($size) < 2) {
         return false;
     }

     $data = [];
 }}}
 .....

--

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


More information about the wp-trac mailing list