Currently, we do always load the sites a user has access to even though when never requested. Eg most dashboard widgets do not need to fetch all siteIds from the database when someone is a superuser. When someone is a user we still often need to do it but often users maybe do not have access to eg all 50k sites so it should be fast.
Basically we want to lazy load the sites a user has access to. This improves performance quite a bit especially when opening the dashboard and when many requests to request 50k sites in parallel. On a fast server the difference is not that obvious but one can feel it is faster.
In general, looks good to me, can merge when comment threads are dealt w/.
fyi: the build was broken at this commit: https://travis-ci.org/piwik/piwik/jobs/58851183
edit: any idea why it broke the build?