@tsteur opened this Issue on December 23rd 2021 Member

See below error. seems this happened when comparing? A segment is applied too but could be removed when reproducing I would assume.

Error: {"message":"Argument 1 passed to Davaxi\Sparkline::setLineColorHex() must be of the type string, null given, called in \/core\/Visualization\/Sparkline.php on line 189","file":"\/vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php","line":74,"request_id":"b59e6","backtrace":" on \/vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php(74)\n#0 \/core\/Visualization\/Sparkline.php(189): Davaxi\Sparkline->setLineColorHex(NULL, 1)\n#1 \/core\/Visualization\/Sparkline.php(106): Piwik\Visualization\Sparkline->setSparklineColors(Object(Davaxi\Sparkline), 1)\n#2 \/plugins\/CoreVisualizations\/Visualizations\/Sparkline.php(105): Piwik\Visualization\Sparkline->main()\n#3 \/core\/Plugin\/Report.php(320): Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline->render()\n#4 \/plugins\/CoreHome\/Controller.php(61): Piwik\Plugin\Report->render()\n#5 [internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(Object(Piwik\Plugins\VisitFrequency\Reports\Get))\n#6 \/core\/FrontController.php(619): call_user_func_array(Array, Array)\n#7 \/core\/FrontController.php(168): Piwik\FrontController->doDispatch('VisitFrequency', 'get', Array)\n#8 \/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#9 \/index.php(25): require_once('\/c...')\n#10 {main}","safemode_backtrace":"#0 [internal function]: Piwik\Plugins\Cloud\Controller->safemode(Array)\n#1 \/core\/FrontController.php(619): call_user_func_array(Array, Array)\n#2 \/core\/FrontController.php(168): Piwik\FrontController->doDispatch('Cloud', 'safemode', Array)\n#3 \/core\/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)\n#4 \/core\/FrontController.php(139): Piwik\FrontController::(Array)\n#5 \/core\/FrontController.php(189): Piwik\FrontController::(Object(TypeError))\n#6 \/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#7 \/index.php(25): require_once('\/c...')\n#8 {main}"}

URL: https://example.matomo.org/index.php?forceView=1&viewDataTable=sparkline&module=VisitFrequency&action=get&idSite=1&period=year&date=2021-01-01,2021-12-31&segment=userId=@test&comparePeriods[]=year&compareDates[]=2020-01-01&compareSegments=&showtitle=1&random=159&columns=nb_actions_returning&colors=%7B%22backgroundColor%22%3A%22%23ffffff%22%2C%22lineColor%22%3A%5B%22%23558b2f%22%2Cnull%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&idSite=1&period=day&date=yesterday

GET: {"forceView":"1","viewDataTable":"sparkline","module":"VisitFrequency","action":"get","idSite":"1","period":"year","date":"2021-01-01,2021-12-31","segment":"userId=@test","comparePeriods":["year"],"compareDates":["2020-01-01"],"compareSegments":"","showtitle":"1","random":"159","columns":"nb_actions_returning","colors":"{\"backgroundColor\":\"#ffffff\",\"lineColor\":[\"#558b2f\",null],\"minPointColor\":\"#ff7f7f\",\"maxPointColor\":\"#75bf7c\",\"lastPointColor\":\"#55aaff\",\"fillColor\":\"#ffffff\"}"}

@sgiehl commented on December 23rd 2021 Member
@diosmosis commented on December 23rd 2021 Member

I'm not able to reproduce. If null is being used, then it is coming from ColorManager not the comparison service (if the color wasn't there in the comparison service, we'd get undefined). The best change I could come up with is: https://github.com/matomo-org/matomo/pull/18536 in case it's a race condition of some kind.

@tsteur commented on December 31st 2021 Member

Also getting similar fatal errors for a different method. This one I can reproduce on our own instance.

Error: {"message":"Argument 1 passed to Davaxi\Sparkline::setBackgroundColorHex() must be of the type string, null given, called in /core\/Visualization\/Sparkline.php on line 183","file":"/vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php","line":54,"request_id":"57701","backtrace":" on /vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php(54)\n#0 /core\/Visualization\/Sparkline.php(183): Davaxi\Sparkline->setBackgroundColorHex(NULL)\n#1 /core\/Visualization\/Sparkline.php(106): Piwik\Visualization\Sparkline->setSparklineColors(Object(Davaxi\Sparkline), 0)\n#2 /plugins\/CoreVisualizations\/Visualizations\/Sparkline.php(105): Piwik\Visualization\Sparkline->main()\n#3 /core\/Plugin\/Report.php(320): Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline->render()\n#4 /plugins\/CoreHome\/Controller.php(61): Piwik\Plugin\Report->render()\n#5 [internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(Object(Piwik\Plugins\API\Reports\Get))\n#6 /core\/FrontController.php(619): call_user_func_array(Array, Array)\n#7 /core\/FrontController.php(168): Piwik\FrontController->doDispatch('API', 'get', Array)\n#8 /core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#9 /index.php(25): require_once('/c...')\n#10 {main}","safemode_backtrace":"#0 [internal function]: Piwik\Plugins\Cloud\Controller->safemode(Array)\n#1 \/core\/FrontController.php(619): call_user_func_array(Array, Array)\n#2 \/core\/FrontController.php(168): Piwik\FrontController->doDispatch('Cloud', 'safemode', Array)\n#3 \/core\/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)\n#4 \/core\/FrontController.php(139): Piwik\FrontController::(Array)\n#5 \/core\/FrontController.php(189): Piwik\FrontController::(Object(TypeError))\n#6 \/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#7 \/index.php(25): require_once('\/c...')\n#8 {main}"}

URL: https://example.matomo.org/index.php?date=2021-11-30,2021-12-29&forceView=1&viewDataTable=sparkline&module=API&action=get&disableLink=0&widget=1&idSite=1&period=day&columns=nb_visits%2Cnb_uniq_visitors&colors=%7B%22lineColor%22%3A%22%23cac5be%22%2C%22minPointColor%22%3A%22%23ff7272%22%2C%22maxPointColor%22%3A%22%237cc282%22%2C%22lastPointColor%22%3A%22%2355b3ff%22%7D

Referrer: https://example.matomo.org/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday

GET: {"date":"2021-11-30,2021-12-29","forceView":"1","viewDataTable":"sparkline","module":"API","action":"get","disableLink":"0","widget":"1","idSite":"1","period":"day","columns":"nb_visits,nb_uniq_visitors","colors":"{\"lineColor\":\"#cac5be\",\"minPointColor\":\"#ff7272\",\"maxPointColor\":\"#7cc282\",\"lastPointColor\":\"#55b3ff\"}"}

@tsteur commented on December 31st 2021 Member

not sure if related, also seeing such a notice
image

@tsteur commented on December 31st 2021 Member

It doesn't look vue related. Quick fix might be in PHP to default the missing/incorrect colors

@tsteur commented on January 27th 2022 Member

We have applied this fix on production but the errors are still happening.

Error: {"message":"Davaxi\Sparkline::setBackgroundColorHex(): Argument #1 ($color) must be of type string, null given, called in \/core\/Visualization\/Sparkline.php on line 185","file":"\/vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php","line":54,"request_id":"007b6","backtrace":" on \/vendor\/davaxi\/sparkline\/src\/Sparkline\/StyleTrait.php(54)\n#0 \/core\/Visualization\/Sparkline.php(185): Davaxi\Sparkline->setBackgroundColorHex(NULL)\n#1 \/core\/Visualization\/Sparkline.php(106): Piwik\Visualization\Sparkline->setSparklineColors(Object(Davaxi\Sparkline), 0)\n#2 \/plugins\/CoreVisualizations\/Visualizations\/Sparkline.php(105): Piwik\Visualization\Sparkline->main()\n#3 \/core\/Plugin\/Controller.php(257): Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline->render()\n#4 \/plugins\/MultiSites\/Controller.php(119): Piwik\Plugin\Controller->renderView(Object(Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline))\n#5 [internal function]: Piwik\Plugins\MultiSites\Controller->getEvolutionGraph()\n#6 \/core\/FrontController.php(619): call_user_func_array(Array, Array)\n#7 \/core\/FrontController.php(168): Piwik\FrontController->doDispatch('MultiSites', 'getEvolutionGra...', Array)\n#8 \/core\/dispatch.php(32):

URL: https://example.matomo.org/index.php?module=MultiSites&action=getEvolutionGraph&period=day&date=2021-12-23,2022-01-21&evolutionBy=nb_visits&columns=nb_visits&idSite=4&idsite=4&viewDataTable=sparkline&colors=%7B%22lineColor%22%3A%22%23cac5be%22%2C%22minPointColor%22%3A%22%23ff7272%22%2C%22maxPointColor%22%3A%22%237cc282%22%2C%22lastPointColor%22%3A%22%2355b3ff%22%7D

Referrer: https://example.matomo.org/index.php?module=MultiSites&action=index&idSite=1&period=day&date=yesterday

@tsteur commented on January 27th 2022 Member

I can also reproduce this locally and something like below fixed it for me

diff --git a/core/Visualization/Sparkline.php b/core/Visualization/Sparkline.php
index e3cff4fb11..c960dea8eb 100644
--- a/core/Visualization/Sparkline.php
+++ b/core/Visualization/Sparkline.php
@@ -179,6 +179,8 @@ class Sparkline implements ViewInterface

         if (empty($colors)) { // quick fix so row evolution sparklines will have color in widgetize's iframes
             $colors = $defaultColors;
+        } else {
+            $colors = array_merge($defaultColors, $colors);
         }

         if (strtolower($colors['backgroundColor']) !== '#ffffff') {
This Issue was closed on January 28th 2022
Powered by GitHub Issue Mirror