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

WordPress Trac noreply at wordpress.org
Thu Jun 19 16:21:14 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:  6.9
Component:  Gallery                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  test-info                                      |
-------------------------------------------------+-------------------------
Changes (by SirLouen):

 * keywords:  has-patch has-test-info has-unit-tests needs-testing => has-
     patch has-unit-tests needs-test-info


Comment:

 @dd32 how can you make that the gallery items have no attached IDs?

 I'm unable to reproduce this just by calling to
 `get_post_galleries($post_id, false);` as you suggest.
 I'm not confident that the reproduction report of rolly is what you mean,
 afaik, thereis not `id` but `ids`

 [[Image(https://i.imgur.com/ixkOdLm.png)]]

 I understand that you can trigger this when `ids` happens to be empty and
 the function is trying to pluck an empty string throwing such error. But I
 have not found a way to create a gallery that has an empty `ids` string.

 If I add a gallery without images, this is the result
 [[Image(https://i.imgur.com/z45bvB5.png)]]

 and no array at all
 [[Image(https://i.imgur.com/3ZNMGK7.png)]]

 If you are asking at this moment why I have put screenshots instead the
 text? Only god knows, I was thinking this right now, but it's too late now
 for me to rollback

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


More information about the wp-trac mailing list