[wp-trac] [WordPress Trac] #46322: PHP 7.2 Warning
WordPress Trac
noreply at wordpress.org
Fri Feb 22 16:29:58 UTC 2019
#46322: PHP 7.2 Warning
--------------------------+-----------------------------
Reporter: good3n | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I get the PHP warning
`Warning: count(): Parameter must be an array or an object that implements
Countable in /path/to/wordpress/wp-includes/post-template.php on line 293`
every time I programmatically create a post with `wp_insert_post()`
If I go back into the post via the admin UI and update it, the warning
goes away.
I'm assuming because PHP 7.2 treats this as NULL.
If I edit the `/wp-includes/post-template.php` file it removes the
warning.
Before (Warning):
{{{#!php
<?php
if ( $page > count( $pages ) ) { // if the requested page doesn't exist
$page = count( $pages ); // give them the highest numbered page that
DOES exist
}
}}}
After (No Warning):
{{{#!php
<?php
if(!empty($pages)) {
if ( $page > count( $pages ) ) { // if the requested page doesn't exist
$page = count( $pages ); // give them the highest numbered page that
DOES exist
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46322>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list