Skip to content

Media: Guard against false return from wp_get_attachment_image_src() for PHP 8.5#11365

Closed
roshniahuja wants to merge 2 commits intoWordPress:trunkfrom
roshniahuja:trac-64742
Closed

Media: Guard against false return from wp_get_attachment_image_src() for PHP 8.5#11365
roshniahuja wants to merge 2 commits intoWordPress:trunkfrom
roshniahuja:trac-64742

Conversation

@roshniahuja
Copy link
Copy Markdown

Summary

  • Fixes PHP 8.5 warning when list() is used to destructure false returned by wp_get_attachment_image_src()
  • Adds is_array() guards in embed.php (get_oembed_response_data_rich), and media.php (wp_get_attachment_image_src, wp_playlist_shortcode, wp_prepare_attachment_for_js)
  • Adds unit tests for invalid thumbnail scenarios

Trac Ticket

https://core.trac.wordpress.org/ticket/64742

Test Plan

  • PHPUnit tests pass (430 tests in Media + oEmbed suites)
  • Manual test: set _thumbnail_id to a non-existent ID, visit oEmbed endpoint — no warnings, no null thumbnail keys

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props roshniahuja14.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter
Copy link
Copy Markdown
Member

westonruter commented Mar 27, 2026

Thanks for the PR, but there is an existing one linked on the ticket which is nearing merge. See #11073.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants