Opened 12 hours ago
Last modified 92 minutes ago
#64295 reopened defect (bug)
PHP 8.5: Incorrect array access in `wp_read_image_metadata`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Media | Keywords: | has-patch php85 dev-feedback |
| Focuses: | php-compatibility | Cc: |
Description
Parent ticket for all things PHP 8.5: #63061
In recent WP-CLI media tests I noticed a "Cannot use bool as array" error in wp_read_image_metadata in PHP 8.5.
That function uses wp_getimagesize without checking whether it returned false or an array.
Moving to milestone for consideration/visibility, but might be a candidate for 6.9.1.
Change History (13)
This ticket was mentioned in PR #10544 on WordPress/wordpress-develop by @swissspidy.
12 hours ago
#1
This ticket was mentioned in Slack in #core by wildworks. View the logs.
11 hours ago
#4
@
8 hours ago
I ran a quick test using WordPress 6.8.3 with PHP 8.4, and tried uploading a corrupted JPEG file to reproduce the behavior described in this ticket.
Here’s what I found:
getimagesize() throws warnings about corrupted JPEG data
exif_read_data() also reports corruption (invalid COM section, broken structure, etc.)
No fatal errors, but the metadata handling definitely breaks in the same way mentioned in the ticket
Log output for reference:
PHP Warning: getimagesize(): Corrupt JPEG data: 138 extraneous bytes before marker
PHP Notice: exif_read_data(): Image has corrupt COM section: wrong length information
PHP Warning: exif_read_data(): File structure corrupted
PHP Warning: exif_read_data(): Invalid JPEG file
So the issue is definitely reproducible on PHP 8.4.
The ticket still needs a patch to prevent array-access warnings when wp_getimagesize() returns false.
Happy to re-test once a patch is available!
#6
@
4 hours ago
Fix looks good and makes sense.
In recent WP-CLI media tests I noticed a "Cannot use bool as array" error in wp_read_image_metadata in PHP 8.5.
Can we add a similar test to core that fails before your patch?
This ticket was mentioned in Slack in #core by welcher. View the logs.
2 hours ago
#8
@
2 hours ago
- Keywords commit added
This was discussed in the bug scrub today. This can be committed.
#9
@
2 hours ago
In recent WP-CLI media tests I noticed a "Cannot use bool as array" error in wp_read_image_metadata in PHP 8.5.
@swissspidy which test failed?
#12
@
112 minutes ago
- Keywords dev-feedback added; needs-testing commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening to request backport of [61291] to the 6.9 branch.
#13
@
92 minutes ago
@adamsilverstein You can see them here: https://github.com/wp-cli/media-command/actions/runs/19621010923/job/56181370548#step:10:158 - they're all about importing SVGs or PDFs, where no size information seems to be available.
Trac ticket: https://core.trac.wordpress.org/ticket/64295