matomo-org / tag-manager

Free Open Source Matomo Tag Manager - A simple way to manage and maintain all of your (third-party) tags on your website.
https://matomo.org
GNU General Public License v3.0
170 stars 58 forks source link

/matomo/plugins/TagManager/Context/WebContext/JavaScriptTagManagerLoader.php(73): Deprecated - str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated - Matomo 4.15.0 #694

Open tomjensendk opened 1 year ago

tomjensendk commented 1 year ago

Hi

When for instance creating new variables in TagManager we are getting the error /matomo/plugins/TagManager/Context/WebContext/JavaScriptTagManagerLoader.php(73): Deprecated - str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated - Matomo 4.15.0

PHP Version 8.1.2-1ubuntu2.14

Variables etc. are created but the user is shown an error message.

Please advice

snake14 commented 12 months ago

Hi @tomjensendk . That's very strange. Is there any error in your logs just before the deprecation error? The third parameter should be the content of debug.twig, retrieved by the call to this method. The only reason I can think of for that not being populated is a permission issue. If you have preview mode enabled while creating a new variable, try disabling it while creating the variable and then enable preview/debug mode after the new variable has been saved.

tomjensendk commented 12 months ago

Hi @snake14 Disabling preview mode get the error out of sight for the users, there is nothing else in the logs except that error message.

The user whom I testing with has "view" on a website and Tag Mamager: Write + Tag Manager: Publish Live Container and Tag Manager: Use Custom Template if that makes a difference - when I use an Superuser account I do not get the error so I guess it is related to access rights somehow but I do not think I can give any more rights and Tag Manager level?

snake14 commented 12 months ago

Hi @tomjensendk . Yes. That sounds like the issue. The loading of the debug template expects the user to have write access for at least one site. So, you're requesting that a view user with TagManager Write access be able to view the debug? I think that makes sense. I'm thinking that permission check could be updated to check the TagManager permission level. That seems like a good improvement request. However, it will probably only be included in Matomo 5.x as there aren't currently any further releases planned for Matomo 4.x.