New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
count(): Argument #1 ($value) must be of type Countable|array, null given in Sparkline/DataTrait.php #18962
Comments
Hi all, is someone working on this? If not would someone like to assist me in solving this. I am a newbee in OpenSource contributions but not in coding. I already wrote a PHP Unit test for this issue, but according to this PHP Unit test everything works as expected. Your help is appreciated. |
Hi @webwinkelfacturen. Feel free to work on this one. I think this error might actually only appear on PHP 8. |
One more hint: Maybe the bug is in Matomo, but it is also not impossible that the bug (or PHP 8.x-incompatibility) is in https://github.com/davaxi/Sparkline/ (even though there currently all reported issues are fixed). |
Thanks, we will do an installation later this week. We were moving our development server. I thought it should be in davaxi/Sparkline and wrote a test. It seems not to be possible to enter wrong values. Anyway, I will try to reproduce the error and let you know. |
Hi, We were not able to reproduce the error. Could this be caused by a previous release? The bug mentions plugins/CoreVisualizations/Visualizations/Sparkline.php line 107, but in our case this is a closing bracket. We wrote a unit-test for the davaxi plugin because the error occurs there. It is not allowed to add a $series which is not an array. If necessary we are willing to see if we can write a unit-test for core/Visualization/Sparkline.php to show that it is not possible to add a $series that is not an array. Thanks for your advise on this. Sophie |
This one is still occurring. I noticed about 7 of these in the logs the other day. Has the same trace as initial post. |
Thanks for the confirmation. Are you using matomo 4.10.0? |
Hi @webwinkelfacturen , I'm running 4.9.1 |
Ok, thanks I compared 4.9.1 and 4.10.0. There are no differences impacting this error. After performing a careful code-review, I spent quite some time to reproduce the error. Without success. Focus has been on core/Visualization/Sparkline.php, since it seems that there the parameter $data of vendor/davaxi/sparkline/src/Sparkline/DataTrait.php is set. I enclosed the analysis with the name analysis_matomo_issues_28962.txt. If there is someone who wants to help that would be great since I am very curious what the problem is. BTW, this problem gave an opportunity to do a deep dive in the Matomo code and it is well built, easy to read, and nice to work upon! |
Thanks for your efforts there @webwinkelfacturen. You would probably need to try PHP8.1 to reproduce the error - if I'm not mistaken you were testing and unable to reproduce on PHP7.4? |
We've had this one again quite a few times. URL:
|
We've had this problem again. |
This problem happened again. |
Error: {"message":"count(): Argument #1 ($value) must be of type Countable|array, null given","file":"/vendor/davaxi/sparkline/src/Sparkline/DataTrait.php","line":117,"request_id":"10bc1","backtrace":" on /vendor/davaxi/sparkline/src/Sparkline/DataTrait.php(117)\n#0 /vendor/davaxi/sparkline/src/Sparkline/DataTrait.php(117): count(NULL)\n#1 /vendor/davaxi/sparkline/src/Sparkline.php(113): Davaxi\Sparkline->getCount()\n#2 /vendor/davaxi/sparkline/src/Sparkline.php(191): Davaxi\Sparkline->generate()\n#3 /core/Visualization/Sparkline.php(219): Davaxi\Sparkline->display()\n#4 /plugins/CoreVisualizations/Visualizations/Sparkline.php(107): Piwik\Visualization\Sparkline->render()\n#5 /core/Plugin/Report.php(320): Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline->render()\n#6 /plugins/CoreHome/Controller.php(61): Piwik\Plugin\Report->render()\n#7 [internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(Object(Piwik\Plugins\PagePerformance\Reports\Get))\n#8 /core/FrontController.php(626): call_user_func_array(Array, Array)\n#9 /core/FrontController.php(168): Piwik\FrontController->doDispatch('PagePerformance', 'get', Array)
URL: https://example.matomo.org/index.php?date=2021-08-16,2022-03-13&module=PagePerformance&format=html&forceView=1&viewDataTable=sparkline&action=get&idSite=2&period=week&comparePeriods[]=week&compareDates[]=2022-02-28&segment=&widget=&showtitle=1&random=7478&columns=avg_time_dom_processing&colors=%7B%22backgroundColor%22%3A%22%23ffffff%22%2C%22lineColor%22%3A%5B%22%230277bd%22%2C%22%23ff8f00%22%5D%2C%22minPointColor%22%3A%22%23ff7f7f%22%2C%22maxPointColor%22%3A%22%2375bf7c%22%2C%22lastPointColor%22%3A%22%2355aaff%22%2C%22fillColor%22%3A%22%23ffffff%22%7D
Referrer: https://example.matomo.org/index.php?module=CoreHome&action=index&date=yesterday&period=day&idSite=2
GET: {"date":"2021-08-16,2022-03-13","module":"PagePerformance","format":"html","forceView":"1","viewDataTable":"sparkline","action":"get","idSite":"2","period":"week","comparePeriods":["week"],"compareDates":["2022-02-28"],"segment":"","widget":"","showtitle":"1","random":"7478","columns":"avg_time_dom_processing","colors":"{"backgroundColor":"#ffffff","lineColor":["#0277bd","#ff8f00"],"minPointColor":"#ff7f7f","maxPointColor":"#75bf7c","lastPointColor":"#55aaff","fillColor":"#ffffff"}"}
The text was updated successfully, but these errors were encountered: