PHP 8.0 compatibility
-
Hi,
We switched our stack to PHP 8.0 and we expected an issue with your plugin on a fresh install.
`TypeError thrown with message “count(): Argument #1 ($value) must be of type Countable|array, bool given”
Stacktrace:
#13 TypeError in /plugins/page-scroll-to-id/malihu-pagescroll2id.php:377It looks like you define $instances by grabbing an option stored in DB:
$instances=get_option($this->db_prefix.’instances’);
But you didn’t define a default value.
The returned value is false if not defined.
And count($instances) expects $instances to be an iterable/countable now in PHP 8.
Note that the issue goes away as soon as we show the backend login form and only appears on a fresh project auto installed through CLI scripts using composer to install plugins.
- The topic ‘PHP 8.0 compatibility’ is closed to new replies.