Opened 6 months ago
Closed 3 months ago
#61060 closed defect (bug) (invalid)
PHP Warning: Undefined array key 1 in image_constrain_size_for_editor()
Reported by: | fullermetric | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.5 |
Component: | Media | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description (last modified by )
Running PHP 8.1, WordPress 6.5.2, debug.log reports Undefined array key 1 in /.../wp-includes/media.php on line 71
function image_constrain_size_for_editor( $width, $height, $size = 'medium', $context = null ) { global $content_width; $_wp_additional_image_sizes = wp_get_additional_image_sizes(); if ( ! $context ) { $context = is_admin() ? 'edit' : 'display'; } if ( is_array( $size ) ) { $max_width = $size[0]; $max_height = $size[1];
Line 71 is where $max_height
is set, but $size[1]
is undefined.
Change History (6)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
5 months ago
#3
@
5 months ago
Hello @antpb
This is a warning, so I'm not sure if there would be a stack involved. However, this is a cut of what surrounded the error in our debug.log
[23-Apr-2024 15:29:53 UTC] PHP Deprecated: preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in /.../wp-includes/formatting.php on line 3506 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:27 UTC] PHP Warning: Undefined array key 1 in /.../wp-includes/media.php on line 71 [23-Apr-2024 15:30:28 UTC] PHP Warning: Attempt to read property "post_title" on null in /.../wp-content/plugins/js_composer/include/helpers/helpers.php on line 60
https://stackoverflow.com/questions/6426758/php-log-stacktrace-for-warnings
If you can provide us with the php code to stacktrace on warnings and which file to add the code to then I can assist further.
#4
@
5 months ago
- Description modified (diff)
- Summary changed from PHP Warning: Undefined array key 1 in /chroot/home/ab2bb14c/fullerfasteners.com/html/wp-includes/media.php on line 71 to PHP Warning: Undefined array key 1 in image_constrain_size_for_editor()
This could fit better in the support forums.
The log has three different messages:
- I think the
media.php
issue is most likely in your custom theme, with how it adds featured images incategory.php
and/or another archive template. To test that, you could visit your blog's Category and Date archives and check the debug log after viewing each page to check if you have the same number of this warning in the log as the posts without a featured image. For example, the Fastener Blog Hans page might print the warning twice at the same time because it has two posts with empty space in the middle of<!-- post thumbnail --><!-- /post thumbnail -->
. - The "post_title" warning is related to WPBakery Page Builder, and it seems to come from Single Image elements that either do not define an
image
or have some problem with the chosen image. If you edit the Volkel brand product page in the back end, you might find eight of the nine Single Image elements say "Add image" (or if you view Classic Mode, you might see the[vc_single_image]
shortcode). Check that each of them has the desired image, or remove the element. - The
preg_split()
notice comes from passingnull
toconvert_smilies()
when it should only receive a string. See #58476.
Hi @fullermetric thank you for making this ticket! The media team did some investigation in a recent meeting and we're having trouble finding how a
$size
array can only have one value provided. In all of the core functions that lead up to the function the$size
var is passed exactly how it is received so it seems likely there is a plugin or some functionality in your site that is only providing the width value.Is it possible for you to provide a callstack that shows how this function is being called to produce the warning? Thank you!