Skip to content

Commit 87332cf

Browse files
authored
Merge pull request #61 from RhubarbPHP/hotfix/TimeZoneFix
MySQL Repository use mysql server time_zone instead of system_time_zone
2 parents 3abc16b + 177c414 commit 87332cf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Change Log
2+
### 1.6.1
3+
4+
* Changed: When creating connection, use DB time_zone rather than system_time_zone to set repositoryDateTime setting.
25

36
### 1.6
47

src/Repositories/MySql/MySql.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,16 @@ public static function getConnection(StemSettings $settings)
704704
)
705705
);
706706

707-
$timeZone = $pdo->query("SELECT @@system_time_zone");
707+
$timeZone = $pdo->query("SELECT @@time_zone as tz, @@system_time_zone as stz");
708708
if ($timeZone->rowCount()) {
709-
$settings->repositoryTimeZone = new \DateTimeZone($timeZone->fetchColumn());
709+
$timezones = $timeZone->fetch(\PDO::FETCH_ASSOC);
710+
if($timezones['tz'] === 'SYSTEM'){
711+
$settings->repositoryTimeZone = new \DateTimeZone($timezones['stz']);
712+
} else {
713+
$settings->repositoryTimeZone = new \DateTimeZone($timezones['tz']);
714+
}
710715
}
716+
711717
if ($settings->charset) {
712718
$statement = $pdo->prepare("SET NAMES :charset");
713719
$statement->execute(['charset' => $settings->charset]);

0 commit comments

Comments
 (0)