diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-26 13:37:15 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-27 11:20:22 +0100 |
commit | d959ce5f2e3e3eebab7a65beec183d1c541c3902 (patch) | |
tree | 71f14866abba8a67a75268ed677898b6a734014f | |
parent | 2435ed88f9865e4f4f4e014d08f24e0654f47399 (diff) |
Set database session timezone on connection.
fixmystreet.com went down early Sunday morning because the database server had
been upgraded in the past year and was now set to UTC and not local time. This
confused the codebase when it encountered timestamps that could not exist, all
between 1-2am UTC.
Ideally, timestamps in the database should be 'with time zone' or be stored in
UTC, but for now let us set the time zone to the local one upon connection.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet.pm | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d23557fc..407656364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Truncate dates in Open311 output to the second. #2023 - Fix check for visible sub map links after 'Try again'. - Stop race condition when making a new report quickly. + - Set a session timezone in case database server is set differently. - Admin improvements: - Inspectors can set non_public status of reports. #1992 - Default start date is shown on the dashboard. diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm index b30f59472..c8d22fe50 100644 --- a/perllib/FixMyStreet.pm +++ b/perllib/FixMyStreet.pm @@ -154,7 +154,12 @@ sub dbic_connect_info { AutoCommit => 1, pg_enable_utf8 => 1, }; - my $dbic_args = {}; + my $local_time_zone = local_time_zone(); + my $dbic_args = { + on_connect_do => [ + "SET TIME ZONE '" . $local_time_zone->name . "'", + ], + }; return ( $dsn, $user, $password, $dbi_args, $dbic_args ); } |