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.92k stars 2.66k forks source link

Improve type checks in SitesManager API #22704

Closed sgiehl closed 4 weeks ago

sgiehl commented 1 month ago

Description:

While working on another issue I came across the fact, that the SitesManager API currently does not check the type that is provided when creating or updating a measurable.

This makes it possible to create measurables with an invalid type, or update an existing measurable with one.

This PR therefor introduces a check if the provided type exists. When updating an existing site, the type will only be checked if it differs from the previous one. This is done, to ensure that a measurable that already has an invalid type (e.g. due to a removed plugin), is still update-able.

Review

michalkleiner commented 4 weeks ago

Is the tag manager submodule update relevant to the change?

sgiehl commented 4 weeks ago

Yes. They were using a measurable without the related plugin being activated. Without it the tests would fail.