Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#34437 closed defect (bug) (fixed)

The image_downsize filter in wp_prepare_attachment_for_js throws an undefined offset notice.

Reported by: justinbusa's profile justinbusa Owned by: joemcgill's profile joemcgill
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.3.1
Component: Media Keywords: has-patch
Focuses: Cc:


The following code in the wp_prepare_attachment_for_js function throws an undefined offset notice...

if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) {
    if ( ! $downsize[3] )

When isset is added, the noticed goes away...

if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) {
    if ( ! isset( $downsize[3] ) )

Attachments (2)

image_downsize.patch (503 bytes) - added by justinbusa 8 years ago.
34437.diff (577 bytes) - added by joemcgill 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @justinbusa
8 years ago

  • Keywords has-patch added

#2 @justinbusa
8 years ago

  • Keywords dev-feedback added

#3 @joemcgill
8 years ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Owner set to joemcgill
  • Status changed from new to reviewing

Good catch @justinbusa. However, wouldn't using isset() there make that conditional return true if $downsize[3] were set to false through a filter on image_downsize? Perhaps using empty() would be better?

8 years ago

#4 @joemcgill
8 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to 4.7
  • Status changed from reviewing to accepted

34437.diff iterates on image_downsize.patch to use empty() instead of ! isset() to avoid skipping over instances where $downsize[3] has been set to false.

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

7 years ago

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

7 years ago

#7 @joemcgill
7 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in [39107].

Note: See TracTickets for help on using tickets.