Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 3 years ago

#34599 closed defect (bug) (fixed)

PHP warning in wp-admin/includes/images.php

Reported by: skithund's profile skithund Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.3
Component: Media Keywords: has-patch
Focuses: Cc:

Description

After [32545] was committed this is a problem again starting from 4.3

Original ticket #25649

Attachments (2)

34599.diff (363 bytes) - added by skithund 9 years ago.
34599.2.diff (343 bytes) - added by skithund 9 years ago.

Download all attachments as: .zip

Change History (10)

@skithund
9 years ago

#1 @swissspidy
9 years ago

  • Keywords has-patch added

We should probably add a small comment there so it doesn't get removed again.

#2 follow-up: @dd32
9 years ago

Can this instead be switched to if ( $metadata ) { unset( $metadata['...']['..'] ); }?

Having it do isset() followed by unset() is confusing, but a truthy check makes it far mor explicit that the reason could be because it's false.

#3 in reply to: ↑ 2 ; follow-up: @skithund
9 years ago

Replying to dd32:

Can this instead be switched to if ( $metadata ) { unset( $metadata['...']['..'] ); }?

The array is set, but missing image (and data). Here's a $metadata from an audio/mp3.

array (
  'dataformat' => 'mp3',
  'channels' => 2,
  'sample_rate' => 48000,
  'bitrate' => 128004.24543946931953541934490203857421875,
  'channelmode' => 'stereo',
  'bitrate_mode' => 'vbr',
  'lossless' => false,
  'encoder_options' => 'VBR',
  'compression_ratio' => 0.08333609729132117338590290955835371278226375579833984375,
  'fileformat' => 'mp3',
  'filesize' => 11578029,
  'mime_type' => 'audio/mpeg',
  'length' => 724,
  'length_formatted' => '12:04',
  'encoder_settings' => 'Lavf56.25.101',
)

#4 in reply to: ↑ 3 @dd32
9 years ago

Replying to skithund:

The array is set, but missing image (and data). Here's a $metadata from an audio/mp3.

That won't cause a PHP notice or warning under any version of PHP.
What will is when the $metadata value is false as mentioned on the original ticket, and shown here: https://3v4l.org/YNBIg (Note, that the only warning is line 8, and although notices are shown, none are shown for line 4)

Version 0, edited 9 years ago by dd32 (next)

#5 @skithund
9 years ago

After more research, this warning was actually triggered by mp2 file, not mp3. Hence $metadata value was indeed false.

Revised patch incoming.

@skithund
9 years ago

#6 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.4

#7 @SergeyBiryukov
9 years ago

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

In 35554:

Media: Avoid a PHP warning in wp_generate_attachment_metadata() if $metadata is not an array.

This was previously fixed in [25968], but accidentally reverted in [32545].

Props skithund.
Fixes #34599.

Note: See TracTickets for help on using tickets.