Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#43201 closed defect (bug) (fixed)

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/media.php on line 1206

Reported by: codegrau Owned by: SergeyBiryukov
Priority: normal Milestone: 4.9.5
Component: Media Version: 4.9.2
Severity: normal Keywords: good-first-bug has-patch fixed-major
Cc: Focuses:

Description

PHP Warning:

count(): Parameter must be an array or an object that implements Countable in /wp-includes/media.php on line 1206

Attachments (1)

43201.diff (559 bytes ) - added by mrmadhat 9 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
9 years ago

  • Component GeneralMedia
  • Keywords needs-patch good-first-bug added
  • Milestone Awaiting Review4.9.4

Hi @codegrau, welcome to WordPress Trac! Thanks for the report.

This sounds like a plugin incorrectly using the wp_calculate_image_srcset filter and returning a non-array. That said, we should make sure $sources is an array before calling count().

Last edited 9 years ago by SergeyBiryukov (previous) (diff)

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


9 years ago

@mrmadhat
9 years ago

#3 @mrmadhat
9 years ago

Added a patch that checks $sources is an array before calling count()

#4 @SergeyBiryukov
9 years ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 42639:

Media: Avoid a PHP warning in wp_calculate_image_srcset() if a plugin returns a non-array value via wp_calculate_image_srcset filter.

Props mrmadhat, codegrau.
Fixes #43201.

#5 @SergeyBiryukov
9 years ago

  • Keywords has-patch fixed-major added; needs-patch removed
  • Resolution fixed
  • Status closedreopened

Reopening for 4.9.4 consideration.

#6 @dd32
9 years ago

  • Milestone 4.9.44.9.5

Bumping, 4.9.4 has been released.

#7 @SergeyBiryukov
9 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 42669:

Media: Avoid a PHP warning in wp_calculate_image_srcset() if a plugin returns a non-array value via wp_calculate_image_srcset filter.

Props mrmadhat, codegrau.
Merges [42639] to the 4.9 branch.
Fixes #43201.

Note: See TracTickets for help on using tickets.