wp-cli / profile-command

Quickly identify what's slow with WordPress
MIT License
271 stars 29 forks source link

Warning: count(): Parameter must be an array or an object that implements Countable inc/class-logger.php on line 65 #158

Closed Mte90 closed 5 months ago

Mte90 commented 5 years ago

Bug Report

Warning: count(): Parameter must be an array or an object that implements Countable in /home/domain/.wp-cli/packages/vendor/wp-cli/profile-command/inc/class-logger.php on line 65

With this command: wp profile hook --all -spotlight --url=https://www.domain.tld

wojsmol commented 5 years ago

@Mte90 Please post wp --info output.

Mte90 commented 5 years ago
OS:     Linux 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64
Shell:  /bin/bash
PHP binary:     /opt/cpanel/ea-php72/root/usr/bin/php
PHP version:    7.2.18
php.ini used:   /opt/cpanel/ea-php72/root/etc/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/domain/public_html
WP-CLI packages dir:    /home/domain/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.2.0
wojsmol commented 5 years ago

Try remove profile-command package. this issue should be fixed in https://github.com/wp-cli/profile-command/pull/151 (https://github.com/wp-cli/profile-command/pull/151/commits/c612994363d81a37fd560dcad17433413c0f315e).

Mte90 commented 5 years ago

If I remove the package I don't have the command anymore. If I reinstall I get the same error. Looking at the code https://github.com/wp-cli/profile-command/blob/master/inc/class-logger.php#L65 seems that we assert that queries is an array but seems that this is not the default behavior https://codex.wordpress.org/Class_Reference/wpdb#Class_Variables So maybe on line 64 is better to use is_array together with empty to do the check.

swissspidy commented 6 months ago

I know it's been a while, but is this still an issue? Seems like it can't hurt to add an is_array() check there or so.

swissspidy commented 5 months ago

Can't reproduce this.