]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Session.php
change Laconica and Control Yourself to StatusNet in PHP files
[quix0rs-gnu-social.git] / classes / Session.php
index 93fd99baa817ee2a6ddd75c7e16b95094917f746..a94a5dbb995ae6617a1e461033a8776248e9bbd2 100644 (file)
@@ -2,8 +2,8 @@
 /**
  * Table Definition for session
  *
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - a 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
@@ -106,16 +106,26 @@ class Session extends Memcached_DataObject
     {
         self::logdeb("garbage collection (maxlifetime = $maxlifetime)");
 
-        $epoch = time() - $maxlifetime;
+        $epoch = common_sql_date(time() - $maxlifetime);
 
-        $qry = 'DELETE FROM session ' .
-          'WHERE modified < "'.$epoch.'"';
+        $ids = array();
 
         $session = new Session();
+        $session->whereAdd('modified < "'.$epoch.'"');
+        $session->selectAdd();
+        $session->selectAdd('id');
 
-        $result = $session->query($qry);
+        $session->find();
 
-        self::logdeb("garbage collection result = $result");
+        while ($session->fetch()) {
+            $ids[] = $session->id;
+        }
+
+        $session->free();
+
+        foreach ($ids as $id) {
+            self::destroy($id);
+        }
     }
 
     static function setSaveHandler()