[wp-trac] [WordPress Trac] #63577: PHP Warning from `get_post_galleries()` when gallery items lack an ID.

WordPress Trac noreply at wordpress.org
Tue Jun 17 04:21:51 UTC 2025


#63577: PHP Warning from `get_post_galleries()` when gallery items lack an ID.
--------------------------+-----------------------------
 Reporter:  dd32          |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Gallery       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 As implemented in #43826 a PHP warning can be thrown pretty consistently
 with certain block contents

 > E_WARNING: Undefined array key "id" in wp-includes/class-wp-list-
 util.php:170

 This warning can be silenced via #59774, but it's specifically from
 `get_post_galleries()` due to the input that's being passed, as seen in
 the stack trace below:

 {{{
 get_post_galleries( $post = 121142, $html = FALSE )
 wp_list_pluck( $input_list = [0 => ['width' => '188px', 'height' =>
 'auto'], 1 => ['width' => '251px', 'height' => 'auto']], $field = 'id',
 $index_key = ??? )
 WP_List_Util->pluck( $field = 'id', $index_key = NULL )
 }}}

 It seems that we can likely just fix this invalid input to
 `wp_list_pluck()` rather than avoiding the warnings in that function
 specifically.

 Given the code in question is fairly simple, we could just loop over the
 attributes and remove the need for `wp_list_pluck()` entirely. See
 attached PR.

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


More information about the wp-trac mailing list