I am still having the same issue as with 4.9.0 when attempting to “Add a new goal” from the Dashboard:
Add a new Goal
Oops… there was a problem during the request. Maybe the server had a temporary issue, or maybe you requested a report with too much data. Please try again. If this error occurs repeatedly please contact your Matomo administrator for assistance. [See the steps to resolve this issue in the FAQ.](https://matomo.org/faq/troubleshooting/faq_19489/)
WARNING: /plugins/Goals/Controller.php(145): Warning - Invalid argument supplied for foreach() - Matomo 4.9.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: Goals, Action: addNewGoal, In CLI mode: false)
FYI…there are currently NO goals set.
However, just as in 4.9.0, I can access this feature via “Settings >> Websites >> Goals”
Please advise.
It seems it will be fixed in version 4.10.0:
opened 10:08PM - 20 Apr 22 UTC
closed 01:20PM - 25 Apr 22 UTC
Bug
When adding a Goal to a website or measurable that does not already have a goal … results in the following warning and error:
```
WARNING Goals[2022-04-20 21:55:47 UTC] [9e913] /home/matomo4/plugins/Goals/Controller.php(145): Warning - foreach() argument must be of type array|object, null given - Matomo 4.9.0 - 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/Goals/Controller.php(145),#1/plugins/Goals/Controller.php(127),[internal function]: Piwik\Plugins\Goals\Controller->addNewGoal(),#3/core/FrontController.php(631),#4/core/FrontController.php(169),#5/core/dispatch.php(32),#6/index.php(25)
ERROR Piwik\FrontController[2022-04-20 21:55:47 UTC] [9e913] Uncaught exception: /home/matomo4/plugins/Goals/templates/_addEditGoal.twig(20): Variable "ecommerceEnabled" does not exist. [Query: ?date=today&module=Goals&format=html&action=addNewGoal&idGoal=&idSite=29&period=day&segment=&widget=&showtitle=1&random=8971, CLI mode: 0]
```
The actual error doesn't seem to have anything to do with Ecommerce being enabled as enabling it doesn't resolve the error. The error does not appear on other sites where goals already exist.
This is the result of a backtrace:
```
WARNING Goals[2022-04-20 22:05:13 UTC] [545cf] /home/matomo4/plugins/Goals/Controller.php(145): Warning - foreach() argument must be of type array|object, null given - Matomo 4.9.0 - 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/Goals/Controller.php(145),#1/plugins/Goals/Controller.php(127),[internal function]: Piwik\Plugins\Goals\Controller->addNewGoal(),#3/core/FrontController.php(631),#4/core/FrontController.php(169),#5/core/dispatch.php(32),#6/index.php(25)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] Uncaught exception: /home/matomo4/plugins/Goals/templates/_addEditGoal.twig(20): Variable "ecommerceEnabled" does not exist.
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #0 /home/matomo4/tmp/innocraft-staff-richard.alwaysdata.net/templates_c/ea/ea158b7cb562e7ece908b29255ddececaf3713b09a4023dcb962fa32c5f1b965.php(83): __TwigTemplate_007ee7500e73a72cbcff0e0f82a44c2b1e87ac9e0877e4e966b1e6c6d8970fb7->{closure}()
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #1 /home/matomo4/vendor/twig/twig/src/Template.php(394): __TwigTemplate_007ee7500e73a72cbcff0e0f82a44c2b1e87ac9e0877e4e966b1e6c6d8970fb7->doDisplay(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #2 /home/matomo4/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #3 /home/matomo4/tmp/innocraft-staff-richard.alwaysdata.net/templates_c/ca/ca290d028ac2a2efca679136b225995fb27791d94a6554e8e5d03c93b06ffb33.php(55): Twig\Template->display(Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #4 /home/matomo4/vendor/twig/twig/src/Template.php(394): __TwigTemplate_066414c30ac46c4843ac62dcbfeb3891730824aab858689698b85b8656fb6bc6->doDisplay(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #5 /home/matomo4/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #6 /home/matomo4/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #7 /home/matomo4/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #8 /home/matomo4/vendor/twig/twig/src/Environment.php(277): Twig\TemplateWrapper->render(Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #9 /home/matomo4/core/View.php(331): Twig\Environment->render('@Goals/addNewGo...', Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #10 /home/matomo4/core/View.php(316): Piwik\View->renderTwigTemplate()
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #11 /home/matomo4/plugins/Goals/Controller.php(128): Piwik\View->render()
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #12 [internal function]: Piwik\Plugins\Goals\Controller->addNewGoal()
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #13 /home/matomo4/core/FrontController.php(631): call_user_func_array(Array, Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #14 /home/matomo4/core/FrontController.php(169): Piwik\FrontController->doDispatch('Goals', 'addNewGoal', Array)
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #15 /home/matomo4/core/dispatch.php(32): Piwik\FrontController->dispatch()
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #16 /home/matomo4/index.php(25): require_once('/home/innocraft...')
ERROR Piwik\FrontController[2022-04-20 22:05:13 UTC] [545cf] #17 {main} [Query: ?date=today&module=Goals&format=html&action=addNewGoal&idGoal=&idSite=29&period=day&segment=&widget=&showtitle=1&random=9922, CLI mode: 0]
```
* Matomo Version: 4.9.0