yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 151 forks source link

Error: count(): Parameter must be an array or an object that implements Countable #358

Closed gb5256 closed 5 years ago

gb5256 commented 5 years ago

What steps will reproduce the problem?

I have a fresh install with php 7.3. Yii2 runs smoothly but I get an error with the DebugToolbar. The same error happend with php 7.2 on Yii2 last year, but there it was fixed in the meantime.

The error happens when I go to /application/debug. The error message happens in vendor/yiisoft/yii2-debug/src/panels/EventPanel.php, line 67. Error message is: Error: count(): Parameter must be an array or an object that implements Countable

Q A
Yii version 2.0.16.1
PHP version 7.3
Operating system Ubuntu 18.04
gb5256 commented 5 years ago

I have just found out there I had a permission mistake on the runtime/debug/index.data. After setting the permissions straight, it now runs without problem. But the above error message seems strange in this context.

samdark commented 5 years ago

We may check early about erroneous read from file and throw meaningful exception.

machour commented 5 years ago

@gb5256 what did the wrong permissions look like in your case? I'm unable to reproduce the count error

gb5256 commented 5 years ago

@machour The Permission was a 644 and the owner of the file was not www-data, also the owner-group was not the www-data group. Hope that helps.

machour commented 5 years ago

@gb5256 with that configuration, I'm still unable to reproduce.

When index.data belong to another user/group, I'm getting:

2019-03-25 11:05:32 [[::1]][-][-][warning][yii\log\Dispatcher::dispatch] Unable to send log via yii\debug\LogTarget: PHP Warning 'yii\base\ErrorException' with message 'touch(): Utime failed: Permission denied'

which is from:

private function updateIndexFile($indexFile, $summary)
{
     touch($indexFile); // <- here
     if (($fp = @fopen($indexFile, 'r+')) === false) {
         throw new InvalidConfigException("Unable to open debug data index file: $indexFile");
     }

I'm going to make that throw the InvalidConfigException instead.

Are you able to reproduce the count error message with yii2-debug dev-master ? If not, let's close this issue for now.

yii-bot commented 5 years ago

It has been 2 or more weeks with no response on our request for more information. In order for our issue tracker to be effective, we are closing this issue.

If you want it to be reopened again, feel free to supply us with the requested information.

Thanks!

This is an automated comment, triggered by adding the label expired.