From 66407a75d1eced92d0bd725caa028f54a3b345be Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sat, 08 Jun 2013 13:53:04 -0400 Subject: [PATCH] Fix date format issues on MS SQL Server (#1488918) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_db_mssql.php | 12 ++++++++++++ program/lib/Roundcube/rcube_db.php | 4 +++- program/lib/Roundcube/rcube_db_sqlsrv.php | 12 ++++++++++++ 4 files changed, 28 insertions(+), 1 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f986e25..a601dd2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix date format issues on MS SQL Server (#1488918) - Fix so non-inline images aren't skipped on forward (#1489150) - Add imap_cache_ttl option to configure TTL of imap_cache - Make LDAP cache engine configurable via ldap_cache and ldap_cache_ttl options diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 086fd66..597fa75 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -368,8 +368,10 @@ */ protected function _query($query, $offset, $numrows, $params) { + $query = trim($query); + // Read or write ? - $mode = preg_match('/^(select|show)/i', ltrim($query)) ? 'r' : 'w'; + $mode = preg_match('/^(select|show|set)/i', $query) ? 'r' : 'w'; $this->db_connect($mode); diff --git a/program/lib/Roundcube/rcube_db_mssql.php b/program/lib/Roundcube/rcube_db_mssql.php index 7131707..4c005b0 100644 --- a/program/lib/Roundcube/rcube_db_mssql.php +++ b/program/lib/Roundcube/rcube_db_mssql.php @@ -46,6 +46,18 @@ } /** + * Driver-specific configuration of database connection + * + * @param array $dsn DSN for DB connections + * @param PDO $dbh Connection handler + */ + protected function conn_configure($dsn, $dbh) + { + // Set date format in case of non-default language (#1488918) + $this->query("SET DATEFORMAT ymd"); + } + + /** * Return SQL function for current time and date * * @param int $interval Optional interval (in seconds) to add/subtract diff --git a/program/lib/Roundcube/rcube_db_sqlsrv.php b/program/lib/Roundcube/rcube_db_sqlsrv.php index 9958dc2..88473e2 100644 --- a/program/lib/Roundcube/rcube_db_sqlsrv.php +++ b/program/lib/Roundcube/rcube_db_sqlsrv.php @@ -46,6 +46,18 @@ } /** + * Driver-specific configuration of database connection + * + * @param array $dsn DSN for DB connections + * @param PDO $dbh Connection handler + */ + protected function conn_configure($dsn, $dbh) + { + // Set date format in case of non-default language (#1488918) + $this->query("SET DATEFORMAT ymd"); + } + + /** * Return SQL function for current time and date * * @param int $interval Optional interval (in seconds) to add/subtract -- Gitblit v1.9.1