#47395 closed defect (bug) (duplicate)
Countable Error in meta.php
| Reported by: | mattgates | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Options, Meta APIs | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Warning: count(): Parameter must be an array or an object that implements Countable in wp-includes/meta.php on line 210
This error prevents any posts from being updated. It seems it is erroring because $old_value may not always be an array.
This is the original line that causes errors:
if ( count( $old_value ) == 1 ) {
The fix checks to see if $old_value is an object or array:
if ( (is_array($old_value) || is_object($old_value)) && count( $old_value ) == 1 ) {
After fix is implemented, everything seems to work fine.
Attachments (4)
Change History (11)
#2
@
7 years ago
- Keywords needs-refresh added
- Milestone Awaiting Review → 5.3
We could use the is_countable() polyfill added in #43583.
#3
@
7 years ago
I think is_countable() function added in PHP 7.3 . How to deal with the previous version?
#4
@
7 years ago
is_countable works best and takes care of the two codes. Appreciate the update! Hopefully see it in the core! Every time WordPress gets an update, i have to add this code in there for PHP 7.3.
#5
@
7 years ago
- Keywords needs-refresh removed
- Milestone 5.3
- Resolution → duplicate
- Severity blocker → normal
- Status new → closed
- Version 5.2.1
Duplicate of #46660.
#6
@
7 years ago
- Keywords needs-refresh added
- Severity normal → blocker
- Version → 5.2.1
Hey @mattgates
is_countable is available in WP core from 4.9.6 https://developer.wordpress.org/reference/since/4.9.6/ but my point was that if you using any PHP lower version i.e. 7.2 or 5.6 then you will get Fatal error
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch