Make WordPress Core

Opened 7 years ago

Closed 7 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's profile codegrau Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.9.5 Priority: normal
Severity: normal Version: 4.9.2
Component: Media Keywords: good-first-bug has-patch fixed-major
Focuses: Cc:

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 7 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Media
  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 4.9.4

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

This sound 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().

Version 0, edited 7 years ago by SergeyBiryukov (next)

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


7 years ago

@mrmadhat
7 years ago

#3 @mrmadhat
7 years ago

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

#4 @SergeyBiryukov
7 years ago

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

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
7 years ago

  • Keywords has-patch fixed-major added; needs-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 4.9.4 consideration.

#6 @dd32
7 years ago

  • Milestone changed from 4.9.4 to 4.9.5

Bumping, 4.9.4 has been released.

#7 @SergeyBiryukov
7 years ago

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

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.