#47395 closed defect (bug) (duplicate)
Countable Error in meta.php
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | has-patch |
Focuses: | Cc: |
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
@
6 years ago
- Keywords needs-refresh added
- Milestone changed from Awaiting Review to 5.3
We could use the is_countable()
polyfill added in #43583.
#3
@
6 years ago
I think is_countable() function added in PHP 7.3 . How to deal with the previous version?
#4
@
6 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
@
6 years ago
- Keywords needs-refresh removed
- Milestone 5.3 deleted
- Resolution set to duplicate
- Severity changed from blocker to normal
- Status changed from new to closed
- Version 5.2.1 deleted
Duplicate of #46660.
#6
@
6 years ago
- Keywords needs-refresh added
- Severity changed from normal to blocker
- Version set to 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
Patch