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

Fix for undefined array index error when rendering sparklines #19275

Closed
AltamashShaikh opened this issue May 26, 2022 · 2 comments · Fixed by #19294
Closed

Fix for undefined array index error when rendering sparklines #19275

AltamashShaikh opened this issue May 26, 2022 · 2 comments · Fixed by #19294
Assignees
Labels
Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@AltamashShaikh
Copy link
Contributor

CoreVisualizations - [Warning] Undefined index CoreVisualizations/Visualizations/Sparklines.php(292)

Expected Behavior

Should handle such undefined index in the code

Current Behavior

Just noticed this, when trying to debug a bug for other plugin there are too many warnings of undefined index in CoreVisualizations/Visualizations/Sparklines.php(292)

To reproduce the error, access Matomo dashboard and tail matomo.log - tail -f /var/www/html/work/matomo/tmp/logs/matomo.log | grep -i Warning
You will see following warning in the log file

Sample Error message

WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_visits - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_uniq_visitors - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_pageviews - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_uniq_pageviews - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_users - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_searches - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_keywords - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_downloads - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_uniq_downloads - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_outlinks - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: nb_uniq_outlinks - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)
WARNING CoreVisualizations[2022-05-26 06:50:01 UTC] [d3452] /var/www/html/work/matomo/plugins/CoreVisualizations/Visualizations/Sparklines.php(292): Notice - Undefined index: max_actions - Matomo 4.11.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) #0/plugins/CoreVisualizations/Visualizations/Sparklines.php(292),#1/plugins/CoreVisualizations/Visualizations/Sparklines.php(108),#2/core/Plugin/Report.php(320),#3/plugins/CoreHome/Controller.php(60),[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(),#5/core/FrontController.php(631),#6/core/FrontController.php(169),#7/core/dispatch.php(32),#8/index.php(25)

Screenshot from 2022-05-26 12-25-05

Possible Solution

Steps to Reproduce (for Bugs)

Context

Your Environment

  • Matomo Version:
  • PHP Version:
  • Server Operating System:
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@AltamashShaikh AltamashShaikh added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label May 26, 2022
@bx80 bx80 added Regression Indicates a feature used to work in a certain way but it no longer does even though it should. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels May 29, 2022
@bx80 bx80 self-assigned this May 29, 2022
@bx80 bx80 added this to the 4.11.0 milestone May 29, 2022
@bx80
Copy link
Contributor

bx80 commented May 29, 2022

This is a regression from #19057

@sgiehl
Copy link
Member

sgiehl commented May 30, 2022

@bx80 a simple isset check should fix that here:

if ($columnMetrics[$column[$i]]) {

@justinvelluppillai justinvelluppillai changed the title CoreVisualizations - [Warning] Undefined index CoreVisualizations/Visualizations/Sparklines.php(292) Fix for undefined array index error when rendering sparklines Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants