]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Session.php
Update to biz theme's input styles
[quix0rs-gnu-social.git] / classes / Session.php
index a92ce405b518f34dbe03c93a90c6591d4d2e9eb7..79a69a96ea3dc11b1f93672890f1687f2e263fa0 100644 (file)
@@ -2,8 +2,8 @@
 /**
  * Table Definition for session
  *
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -19,7 +19,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
@@ -85,9 +85,18 @@ class Session extends Memcached_DataObject
 
             return $session->insert();
         } else {
-            $session->session_data = $session_data;
+            if (strcmp($session->session_data, $session_data) == 0) {
+                self::logdeb("Not writing session '$id'; unchanged");
+                return true;
+            } else {
+                self::logdeb("Session '$id' data changed; updating");
+
+                $orig = clone($session);
+
+                $session->session_data = $session_data;
 
-            return $session->update();
+                return $session->update($orig);
+            }
         }
     }
 
@@ -108,20 +117,24 @@ class Session extends Memcached_DataObject
 
         $epoch = common_sql_date(time() - $maxlifetime);
 
+        $ids = array();
+
         $session = new Session();
         $session->whereAdd('modified < "'.$epoch.'"');
+        $session->selectAdd();
+        $session->selectAdd('id');
 
         $session->find();
 
         while ($session->fetch()) {
-            $other = new Session();
-            $other->id = $session->id;
-            self::logdeb("Collecting session $other->id");
-            $result = $other->delete();
-            self::logdeb("garbage collection result = $result");
+            $ids[] = $session->id;
         }
 
         $session->free();
+
+        foreach ($ids as $id) {
+            self::destroy($id);
+        }
     }
 
     static function setSaveHandler()