Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#48324 closed defect (bug) (fixed)

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

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

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 7 years ago.
fix as proposed in the ticket
48324.1.diff​ (682 bytes ) - added by Hareesh Pillai 7 years ago.
Patch updated as per the latest comment

Download all attachments as: .zip

Change History (9)

@Mte90
7 years ago

fix as proposed in the ticket

#1 @Mte90
7 years ago

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

#2 @desrosj
7 years ago

  • Milestone Awaiting Review → 5.3.1
  • Version 5.2.3 → 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.


7 years ago

#4 @jrf
7 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 7 years ago by jrf (previous) (diff)

@Hareesh Pillai
7 years ago

Patch updated as per the latest comment

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


7 years ago

#6 @SergeyBiryukov
7 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → 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
7 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.