@tsteur opened this Issue on December 21st 2017 Owner

Background: Custom Dimensions defines Dimensions and Metrics depending on the requested site. However, all dimensions and metrics are fetched site independent. This is usually not a problem as only one site is fetched per request anyway. However, it is a problem when archiving eg a roll-up which may also trigger the archiving of individual sites within that roll-up.

In this case eg a URL is request &idSite=16 but it also triggers eg the archiving of idSite = 1. Custom Dimensions will then search for dimensions of the site 16 even though we are archiving idSite 1. Even worse this result will be cache site-independent and used for all sites.

We basically need to refactor all Dimension and Metric related method to optionally be requested site-specific. Especially eg these methods:

  • DimensionProvider::getAllDimensions() => could be eg getAllDimensionsForSite()
  • DimensionProvider::factory() => could be eg factoryForSite()
  • Dimension::getAllDimensions()
  • ActionDimension::getAllDimensions()
  • VisitDimension::getAllDimensions()
  • ConversionDimension::getAllDimensions()
  • MetricsList::get() would need to be eg MetricsList::getForSite().

Because it needs to be backwards compatible we ideally introduce new methods for this as otherwise it will be hard for plugins to be compatible for eg Piwik 3.0 and eg Piwik 3.3. Any of those methods that use a cache, whether it is a static property or transient cache, need to be made site specific.

As a result, we also need to update all plugins that have been using any of those methods so far and check whether those instead need to use the method that fetches it by idSite.

Note that some methods won't call the method site specific on purpose, eg the column update checker. We need to check all methods where those methods are called in core whether it actually needs to be requested by site or "overall". Then also update / refactor the methods that call those methods as they might now need an idSite parameter as well.

It may take a while to make this change.

Powered by GitHub Issue Mirror