Opened 6 years ago
Closed 6 years ago
#46445 closed defect (bug) (duplicate)
Parameter must be an array or an object that implements Countable
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\wordpress\wp-includes\post-template.php on line 293
Getting the warning when I use "get_the_excerpt()" in wp_head hook.
Change History (3)
#1
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from assigned to closed
#2
@
6 years ago
- Resolution invalid deleted
- Status changed from closed to reopened
We are seeing our logs fill up with this error since moving to PHP 7.2
The error doesn't happen for normal circumstances but happens when we have people probing our site for vulnerabilities where their query string results in the global $pages being returned as null which isn't countable.
An example query string that triggered it for us is the following: index.php?s=%2Fmodule%2Faction%2Fparam1%2F%24%7B%40print%28eval%28%24_POST%5Bc%5D%29%29%7D
decoded as index.php?s=/module/action/param1/${@print(eval($_POST[c]))}
It appears that certain conditions can get Wordpress to result in null for $pages and so the code needs to check that $pages are countable.
I can't reproduce this with a default theme and no plugins enabled using the following test code on php 7.3.2
It sounds like a plugin or theme is overriding the $pages global and setting it to the wrong object type.