maul75
(Maul75)
April 14, 2022, 6:41am
1
Hi,
the following error occurs after update to 4.9.0 if there are already no goals defined and want to create a new goal.
WARNING: /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) (Module: Goals, Action: addNewGoal, In CLI mode: false)
Accius
(Francesco)
April 14, 2022, 3:35pm
4
I have the same issue too
velocity08
(Gerardo Altman)
April 15, 2022, 3:57am
5
seeing the same here.
self hosted
php 8.17
Matomo 4.9
nginx/1.18.0
memory limit 256MB
let me know how else we can assist in troubleshooting.
im re editing this post with more info.
if i use the action “add a goal” from the “Become A Matomo Expert” menu.
see image.
then we can add a goal.
it also pops up with this error when creating using the above workflow.
The string General_Description was not loaded in javascript. Make sure it is added in the Translate.getClientSideTranslationKeys hook.
hope the above helps fix this bug.
""Cheers
G
@velocity08 , your issue seems not the same as the one of Francesco, paprika or Maul75…
in your case, have a look at:
@dori44 Do you by any chance have the TagManager disabled? If so that could be the reason why that string is not loaded. But it for sure should also work with disabled TagManager. I’ll create a PR to ensure this works in next release.
velocity08
(Gerardo Altman)
April 15, 2022, 8:02am
7
Hi @heurteph-ei
actually it is the exact same error with the same warnings precisely.
i just didn’t upload the same errors as they where already presented and simply referenced the same error as the original poster Maul75 and the next poster paprika.
i had no goals defined and the error that popped up is identical in both cases.
the difference is that i found a work around to create a goal which is why i edited my post after finding it and provided the info for others.
even after creating a goal there are other elements broken on page.
see attached image.
hope this helps.
""Cheers
G
velocity08
(Gerardo Altman)
April 15, 2022, 8:03am
8
since im limited to posting 1 image per post ive had to add another reply with the other image.
""Cheers
G
OK.
Maybe you encounter several different problems…
Can you try the Stefan Giehl solution, just for the test of translations?
Then for the other error:
When did it happen the first time? After a PHP update? After Matomo update (from/to which versions)?
What kind of errors do you see in the JavaScript console and in the Network log of the developer tool of your browser?
velocity08
(Gerardo Altman)
April 15, 2022, 8:15am
10
after replying to your message i took your advise and enabled tag manager (which i didn’t know existed)
and the errors ive pointed out in the screen shots went away.
WTF?
some how these items are linked i have no idea how or why but they are now all working after enabling tag manager.
thank you for the tip greatly appreciated
""Cheers
G
velocity08
(Gerardo Altman)
April 15, 2022, 8:19am
12
yep 100% as advised
there is some intrinsic link here that shouldn’t exist but it does - lol.
there may be some code in the general section that’s cross referencing code in the tag manager, when its disabled there is a block and the errors we have all been referencing.
once TM is enabled the code is accessible and working.
that’s me trying to logically pull it apart.
is tag manager a new 4.9 feature?
""Cheers
G
No it is an old feature, but the UI framework changed recently from AngularJS to Vue…
velocity08
(Gerardo Altman)
April 15, 2022, 8:36am
14
yep cool.
this should fix it for the other users.
thanks again for pointing me to this fix.
""Cheers
G
After upgrading my on-premise install to 4.9.0, I’m also see the same thing as in parprika’s screen shot above. Using Chrome Developer Tools, I was able to see this additional information:
The following error just broke Matomo (v4.9.0):
Variable “ecommerceEnabled” does not exist.
in /var/www/analytics.empactcareers.org/docroot/plugins/Goals/templates/_addEditGoal.twig line 20
I have the same issue here (on premise) as both @Maul75 (code) & @paprika (screenshot) when attempting to access the “Add a new Goal” from the Dashboard.
However, if I go to ‘Settings >> Websites >> Goals’, i can setup a new goal from there.
@AgentEccks @Paul_McKibben did you try to enable the Tag Manager?
@heurteph-ei Yes, I have tag manager enabled.
Issue created in backlog:
opened 10:08PM - 20 Apr 22 UTC
Potential 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
@Philippe : Yes, same error with TagManager Activated.