[wp-trac] [WordPress Trac] #54943: PHP Warnings in image_get_intermediate_size() on PHP >= 8
WordPress Trac
noreply at wordpress.org
Mon Aug 7 18:42:26 UTC 2023
#54943: PHP Warnings in image_get_intermediate_size() on PHP >= 8
-----------------------------------------------+---------------------------
Reporter: fhwebdesign | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Media | Version: 5.9
Severity: normal | Resolution:
Keywords: php80 has-patch reporter-feedback | Focuses:
-----------------------------------------------+---------------------------
Changes (by hellofromTonya):
* keywords: php80 has-patch => php80 has-patch reporter-feedback
* type: enhancement => defect (bug)
Comment:
Hello @fhwebdesign,
Welcome to WordPress Core's Trac! Thank you for reporting the issue you
experienced. I'm sorry it's taken so long to welcome you in this ticket.
I'll add some details from your [https://wordpress.org/support/topic/php-
error-trying-to-access-array-offset/ Support Forum report] to help
contributors investigating this problem:
* Happens with a cloned WP site, no plugins and using TT2 (Twenty Twenty-
Two theme):
>So I cloned my website, deactivated all plugins, switched theme to twenty
twentytwo and tried again.
* Does not happen with a fresh new installation with no images or content.
>A completely new WordPress installation does not throw this warning.
>No, there are no images and pages/posts loaded.
I'm evaluating this ticket to determine if it could be a PHP 8.0
compatibility issue within Core.
The Warning in PHP 8.0 you reported is a Notice in PHP 7.4. The Warning
and Notice are alerting developers of a problem.
The code in question ''expects'' the `'size'` element to be an `array` as
documented in `wp_get_attachment_metadata()`:
{{{#!php
* @return array|false {
* Attachment metadata. False on failure.
*
* @type int $width The width of the attachment.
* @type int $height The height of the attachment.
* @type string $file The file path relative to `wp-
content/uploads`.
* @type array $sizes Keys are size slugs, each value is an
array containing
* 'file', 'width', 'height', and 'mime-
type'.
* @type array $image_meta Image metadata.
* @type int $filesize File size of the attachment.
* }
*/
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered =
false ) {
}}}
Reference:
https://developer.wordpress.org/reference/functions/wp_get_attachment_metadata/
I wonder: Why are there no sizes for the attachment(s)? Could the issue be
a callback hooked into filter? Or maybe the metadata is incomplete? Or did
something happen when the attachment was added or edited?
@fhwebdesign can you share steps of how to reproduce the issue? Does it
happen on a specific upload attachment, such as one image? Is this still
happening on your website?
Any additional information you can provide helps contributors like me to
further investigate to determine if the root cause is in the WordPress
Core source code or not.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54943#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list