/**
* 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
{
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()