Skip to content
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

Open
tsteur opened this issue Mar 18, 2022 · 13 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Stability For issues that make Matomo more stable and reliable to run for sys admins.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Mar 18, 2022

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

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Mar 18, 2022
@tsteur tsteur added this to the Priority Backlog (Help wanted) milestone Mar 18, 2022
@webwinkelfacturen
Copy link

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
Copy link
Member

sgiehl commented Apr 25, 2022

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
Copy link
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
Copy link

webwinkelfacturen commented Apr 26, 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
Copy link

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
Copy link
Contributor

samjf commented May 19, 2022

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
Copy link

Thanks for the confirmation. Are you using matomo 4.10.0?

@samjf
Copy link
Contributor

samjf commented May 19, 2022

Hi @webwinkelfacturen , I'm running 4.9.1

@webwinkelfacturen
Copy link

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!

analysis_matomo_issues_28962.txt

@justinvelluppillai
Copy link
Contributor

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
Copy link
Member Author

tsteur commented Nov 28, 2022

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

URL:

date=2020-05-01,2022-10-31&module=PagePerformance&format=html&forceView=1&viewDataTable=sparkline&action=get&idSite=2&period=month&comparePeriods[]=month&compareDates[]=2022-09-01&segment=&widget=&showtitle=1&random=190&columns=avg_time_on_load&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

@tsteur
Copy link
Member Author

tsteur commented Feb 23, 2023

We've had this problem again.

@tsteur
Copy link
Member Author

tsteur commented May 28, 2023

This problem happened again.

@mattab mattab added the Stability For issues that make Matomo more stable and reliable to run for sys admins. label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Stability For issues that make Matomo more stable and reliable to run for sys admins.
Projects
None yet
Development

No branches or pull requests

7 participants