@tsteur opened this Issue on March 18th 2022 Member

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\"}"}

@webwinkelfacturen commented on April 20th 2022

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.

@sgiehl commented on April 25th 2022 Member

Hi @webwinkelfacturen. Feel free to work on this one. I think this error might actually only appear on PHP 8.
It might only occur when certain parameters are given/set. The url provided in the issue description might help to reproduce that locally.

@Findus23 commented on April 25th 2022 Member

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).

@webwinkelfacturen commented on April 26th 2022

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.

@webwinkelfacturen commented on May 4th 2022

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

@samjf commented on May 19th 2022 Contributor

This one is still occurring. I noticed about 7 of these in the logs the other day. Has the same trace as initial post.

@webwinkelfacturen commented on May 19th 2022

Thanks for the confirmation. Are you using matomo 4.10.0?

@samjf commented on May 19th 2022 Contributor

Hi @webwinkelfacturen , I'm running 4.9.1

@webwinkelfacturen commented on May 26th 2022

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_issues28962.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!


@justinvelluppillai commented on May 26th 2022 Member

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?

@tsteur commented on November 28th 2022 Member

We've had this one again quite a few times.



Powered by GitHub Issue Mirror