Conflict using count() under PHP 8.x
-
Hi Bowo,
I got another bug report for you following SD release 2.1.0.
This code fragment from
admin/class-system-dashboard-admin.php
breaks under PHP 8.0 and later with the following error message:[STDERR] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in ..../wp-content/plugins/system-dashboard/admin/<strong>class-system-dashboard-admin.php:2549</strong>
/** * Get # of rewrite rules * * @since 2.1.0 */ public function sd_rewrite_rules_count() { $rewrite_rules = get_option( 'rewrite_rules' ); $output = count( $rewrite_rules ); return $output; }
The reason being that get_option( ‘rewrite_rules’ ) returns an empty result and
8.0.0 count() will now throw TypeError on invalid countable types passed to the value parameter.
Reference: PHP Manual
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conflict using count() under PHP 8.x’ is closed to new replies.