matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.35k stars 2.59k forks source link

PrivacyManager.ipAnonymizerEnabled overwritten on restart #18735

Open darkSideOfPink opened 2 years ago

darkSideOfPink commented 2 years ago

In Matomo 4.6.2 the option PrivacyManager.ipAnonymizerEnabled is overwritten when the pod is restarted.

Expected Behavior

The value of ipAnonymizerEnabled stays the same in the database

Current Behavior

After a restart, the value is changed to 0

Steps to Reproduce (for Bugs)

  1. Start Matomo, go to Administration -> Privacy -> Anonymize data
  2. Check the Anonymize Visitors' IP addresses
  3. Restart Pod
  4. Start Matomo, go to Administration -> Privacy -> Anonymize data

Context

I'm trying to get this working on a OpenShift platform. I'm not allowed to use a PVC

Your Environment

sgiehl commented 2 years ago

@darkSideOfPink Thanks for the report. So is this more likely a display issue? The values is stored correctly in the database, but the UI doesn't reflect it. Or is the UI value only changing after restart?

darkSideOfPink commented 2 years ago

@sgiehl No, it's more then a display issue, it doesn't hide the IP addresses anymore either, the value in de database is changed after restart, so the option is actually altered

sgiehl commented 2 years ago

That sound weird. So the value is changed in the database when you change it in the UI, but is reset when restarting pod? Is there anything done with Matomo or the database upon restart?

darkSideOfPink commented 2 years ago

Yes, I find it weird too. Especially since other values aren't changed. There is nothing done with Matomo or the database upon restart as far as I could track down. Like I said, on my local computer with persistent volume it does work, so it feels like it gets the value from there somewhere and since there isn't a persistent volume, it uses the default? I'm not sure, but like I said, other values (like the amount of bytes obscured) aren't changed

sgiehl commented 2 years ago

Those settings are both stored the same way. So if one gets lost, actually the other one should reset too.

For what exactly are you using a non persistent volume? Matomo requires at least the config to be persistent

Note: There are only two places where the ipAnonymizer is disabled:

And the default value should actually be true...

darkSideOfPink commented 2 years ago

Thank you for your reply. I looked into it. The installation does get called when the pod is restarted because it doesn't have persistant storage (so no config file). I will try to convince the company to use persistant storage. Still find it odd only this value is changed

sgiehl commented 2 years ago

@darkSideOfPink maybe copying in the config file from an external static source might be another option. But not having the config.ini.php persistent is not recommended. As changing some settings in the UI or even when updating Matomo might add/change the config file. And that might get lost on restart in your case and could in some cases even cause other trouble.

qiuminwei commented 1 year ago

@sgiehl I also had this problem: PrivacyManager.ipAnonymizerEnabled is changed in the database when I change it in the UI, but is reset to 0 when restarting the pod.

I don't think it has anything to do with config, because after I changed it in the UI, the config file doesn't change anything.

sgiehl commented 1 year ago

@qiuminwei If your pod is also running the installation on restart as the config file is not persistent, this might be the reason.

qiuminwei commented 1 year ago

@sgiehl thanks for the quick replying, we do not use persistent volume but will copy the preset config.ini.php every time Matomo starts, and I have seen the installation script, it will first check the ipAnonymizerEnabled value in the database, if it is true, it will skip the reset, so I'm confused where exactly this value is reset.

sgiehl commented 1 year ago

That's not the part of the installation I was referring to. The update script should only be executed when Matomo is updated. That shouldn't be the case here. I was referring to this part: https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/PrivacyManager/PrivacyManager.php#L434

But actually we don't have enough time to help narrow down issues for such specific use cases. Feel free to investigate the issue on your own. Maybe by commenting out some lines, that might deactivate it and check where it comes from. If you are able to provide enough details we are happy to fix it. You can also try to find some help on our forum.