From ff4ffc6d546d6d69bedd0018f8fbba40c867e468 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 10 May 2011 03:08:03 -0400
Subject: [PATCH] Revert r4746 due to timestsamp issues with mysql; deprecate rcube_mdb2::unixtimestamp()

---
 program/include/rcube_mdb2.php    |   12 +++++-------
 program/include/rcube_session.php |    5 ++---
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php
index 3658328..a68d1dd 100644
--- a/program/include/rcube_mdb2.php
+++ b/program/include/rcube_mdb2.php
@@ -545,9 +545,12 @@
     /**
      * Return SQL statement to convert a field value into a unix timestamp
      *
+     * This method is deprecated and should not be used anymore due to limitations
+     * of timestamp functions in Mysql (year 2038 problem)
+     *
      * @param  string $field Field name
      * @return string  SQL statement to use in query
-     * @access public
+     * @deprecated
      */
     function unixtimestamp($field)
     {
@@ -574,12 +577,7 @@
      */
     function fromunixtime($timestamp)
     {
-        switch ($this->db_provider) {
-            case 'mysql':
-                return 'FROM_UNIXTIME(' . intval($timestamp) . ')';
-            default:
-                return date("'Y-m-d H:i:s'", $timestamp);
-        }
+        return date("'Y-m-d H:i:s'", $timestamp);
     }
 
 
diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php
index d3da36f..e4d9a87 100644
--- a/program/include/rcube_session.php
+++ b/program/include/rcube_session.php
@@ -131,12 +131,11 @@
   public function db_read($key)
   {
     $sql_result = $this->db->query(
-      sprintf("SELECT vars, ip, %s AS changed FROM %s WHERE sess_id = ?",
-        $this->db->unixtimestamp('changed'), get_table_name('session')),
+      "SELECT vars, ip, changed FROM ".get_table_name('session')." WHERE sess_id = ?",
       $key);
 
     if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
-      $this->changed = $sql_arr['changed'];
+      $this->changed = strtotime($sql_arr['changed']);
       $this->ip      = $sql_arr['ip'];
       $this->vars    = base64_decode($sql_arr['vars']);
       $this->key     = $key;

--
Gitblit v1.9.1