Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#48324 closed defect (bug) (fixed)

Undefined index: full in/wp-includes/media.php on line 214

Reported by: mte90's profile Mte90 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 4.7
Component: Media Keywords: has-patch 2nd-opinion needs-testing
Focuses: Cc:

Description

I don't know why I am getting this error but is very spammy on the log.
After a look inside the code I found the guilty line https://github.com/WordPress/WordPress/blob/5.2-branch/wp-includes/media.php#L211

if ( ! $is_image ) {
	if ( ! empty( $meta['sizes'] ) ) {
		$img_url          = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );
[...]

The fix is quite simple:

if ( ! $is_image ) {
	if ( ! empty( $meta['sizes'] ) && isset( $meta['sizes']['full'] ) ) {
		$img_url          = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );
[...]

From the code seems that doesn't found an attachment size, maybe because I am using the new live_url feature of VVV (https://github.com/Varying-Vagrant-Vagrants/custom-site-template) that let o redirect by nginx the image using a remote, so is not required to have a copy of the files.

Attachments (2)

48324.diff (726 bytes) - added by Mte90 5 years ago.
fix as proposed in the ticket
48324.1.diff (682 bytes) - added by Hareesh Pillai 5 years ago.
Patch updated as per the latest comment

Download all attachments as: .zip

Change History (9)

@Mte90
5 years ago

fix as proposed in the ticket

#1 @Mte90
5 years ago

  • Keywords has-patch 2nd-opinion needs-testing added
  • Version set to 5.2.3

#2 @desrosj
5 years ago

  • Milestone changed from Awaiting Review to 5.3.1
  • Version changed from 5.2.3 to 4.7

Looks like this was introduced in [38949] (see #31050).

I'm adding this to 5.3.1 as this is not a regression. But I'm wondering if the changes related to generating images has caused this notice to become more common.

This ticket was mentioned in Slack in #core-media by mike. View the logs.


5 years ago

#4 @jrf
5 years ago

Had a quick look. IMHO a simpler fix - and just as effective - would be to replace the ! empty( $meta['sizes'] ) with ! empty( $meta['sizes']['full'] ).

Side-note: I do wonder how an image can exist without a full sized version ? Sratch that, just noticed this only applies to non-images.

Last edited 5 years ago by jrf (previous) (diff)

@Hareesh Pillai
5 years ago

Patch updated as per the latest comment

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


5 years ago

#6 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 46772:

Media: Avoid a PHP notice in image_downsize() when trying to replace a non-image URL with a rendered image from its meta.

Props Mte90, jrf, hareesh-pillai.
Fixes #48324.

#7 @SergeyBiryukov
5 years ago

In 46773:

Media: Avoid a PHP notice in image_downsize() when trying to replace a non-image URL with a rendered image from its meta.

Props Mte90, jrf, hareesh-pillai.
Merges [46772] to the 5.3 branch.
Fixes #48324.

Note: See TracTickets for help on using tickets.