hasVisits check uses 22:00 / 23:00 instead of 00:00 - some sites not archived - timezone problem

Since 2015-11 or around Piwik 2.15 i noticed, that some sites were not archived for days, sometimes for weeks.
In the logfile / archiving reposrt i saw “no new tracking data for website id XX”.
The site-IDs were varying, but they all were low traffic sites (<100 users / day).

Archiving is done via cronjob at 02:30 on a daily base.

Today i found the hasVisits-check in core/CronArchive.php, which checks (or should check) if there were visits in a specific site the day before and then does the archiving, otherwise archiving will be skipped for this site.

    if ($hasVisits) {
        $this->logger->info("- tracking data found for website id $idSite (between $from and $to)");
    } else {
        $this->logger->info("- no new tracking data for website id $idSite (between $from and $to)");
    }

My problem now is with $from and $to, because i am in the Europe/Berlin timezone.
In the winter $from was 23:00, now in summer it is 22:00.
The $to uses the time of the current archiving task, so this time varies from start to the end of cron-archiving-task, but it is always started at the next day.

Example:
Day 03.04.2016 gets tracking data from 00:00 to 23:59. My cron-archiving starts at 04.04.2016 02:30

Currently (Berlin, summertime) the hasVisits-check asks, if there was new tracking data between 2016-04-04 22:00:00 and 2016-04-05 01:33:05 … if not it states: Skipped website id XX as archiving is not needed.

With low traffic sites this goes on unitil the first visitor arrives someday between 22:00 and 23:59.
This made this behaviour quite erratic.

Possible solutions:

  • change my timezone settings in Piwik backend (per site, global) to London … but this would change the tracking data
  • change core/CronArchive.php … but this would be overwritten with every update

This behaviour should probably occur in any piwik instance with low traffic sites with deviant timezone settings.

Any hints how to fix this are welcome.

Best regards
Stephan

Hi Stephan,

This looks like you found a bug / edge case in Piwik. Could you please create an issue on our tracker @ Issues · matomo-org/piwik · GitHub and post there your information? it would be useful if you can write “UTC” next to UTC datetimes and “Berlin” next to times when they are converted in Berlin (so it is clear for us). Thank you!

Thank you for the feedback. A new ticket is created here: