Skip to content

Add an optional mysql-timezone input for the database container - #53

Open
snake14 wants to merge 1 commit into
mainfrom
optional-database-timezone
Open

Add an optional mysql-timezone input for the database container#53
snake14 wants to merge 1 commit into
mainfrom
optional-database-timezone

Conversation

@snake14

@snake14 snake14 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Adds an optional mysql-timezone input for the database container. It defaults to UTC, which is what CI has always run, so every existing caller is unaffected and nothing runs differently until someone opts in.

Matomo stores datetimes in UTC, but SQL that reads a date back out of those columns can depend on the database server's timezone — Matomo never pins it, so it is whatever the server defaults to. Because CI is UTC, that whole class of bug passes here and only appears for users whose database server is not on UTC.

That is not theoretical. Cohorts derived each visitor's cohort via UNIX_TIMESTAMP(log_visit.visit_first_action_time), which reads a UTC-stored DATETIME in the session's zone, so every cohort was shifted by that offset — for years, with CI green throughout. It was found by accident on a developer machine in Pacific/Auckland (fix: innocraft/plugin-Cohorts#134).

The input is passed as TZ to the container rather than applied via SET GLOBAL time_zone, so the server reports the zone through @@system_time_zone while @@global.time_zone stays SYSTEM — how such a server is really configured, and a path that a numeric offset set from inside a test never exercises.

Verified against mysql:5.7, the default image:

@@system_time_zone @@global.time_zone NOW() vs UTC_TIMESTAMP()
default (TZ=UTC) UTC SYSTEM identical
TZ=Pacific/Auckland NZST SYSTEM +12h

Deliberately not wired into any caller or matrix here. A timezone axis would double every plugin's PluginTests matrix, and turning it on broadly would surface real but unrelated failures in whichever PR happened to trigger it. The suggested next step is one manual or scheduled run over core and a few plugins to measure the blast radius first.

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Defaults to UTC, so existing callers are unaffected. A non-UTC value reproduces the
condition where SQL reading dates out of Matomo's UTC-stored DATETIME columns returns
a shifted result, which CI cannot currently reach.
@snake14 snake14 added the Needs Review For pull requests that need a code review. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review For pull requests that need a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant