]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
authorEvan Prodromou <evan@controlyourself.ca>
Sun, 2 Aug 2009 14:35:03 +0000 (10:35 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Sun, 2 Aug 2009 14:35:03 +0000 (10:35 -0400)
.gitignore
classes/File.php
classes/Session.php
scripts/sessiongc.php [new file with mode: 0644]

index f4c2bba5f7af504503ab4a03fa2d3faf50d99b2e..5394f5eac54a0c4884d6756b3cc7b31e4df0fe08 100644 (file)
@@ -23,4 +23,4 @@ config-*.php
 good-config.php
 lac08.log
 php.log
-config.php.*
+
index 0c4fbf7e694378a3b195eb7b422e908baa1f51f9..959301edaeff30672bd716326c4aae1420bda476 100644 (file)
@@ -93,7 +93,6 @@ class File extends Memcached_DataObject
         if (empty($file)) {
             $file_redir = File_redirection::staticGet('url', $given_url);
             if (empty($file_redir)) {
-                common_debug("processNew() '$given_url' not a known redirect.\n");
                 $redir_data = File_redirection::where($given_url);
                 $redir_url = $redir_data['url'];
                 if ($redir_url === $given_url) {
@@ -114,7 +113,9 @@ class File extends Memcached_DataObject
 
         if (empty($x)) {
             $x = File::staticGet($file_id);
-            if (empty($x)) die('Impossible!');
+            if (empty($x)) {
+                throw new ServerException("Robin thinks something is impossible.");
+            }
         }
 
         File_to_post::processNew($file_id, $notice_id);
index ac80279c5e300aab9429ffb4e367a00910d434f2..a92ce405b518f34dbe03c93a90c6591d4d2e9eb7 100644 (file)
@@ -110,9 +110,18 @@ class Session extends Memcached_DataObject
 
         $session = new Session();
         $session->whereAdd('modified < "'.$epoch.'"');
-        $result = $session->delete(DB_DATAOBJECT_WHEREADD_ONLY);
 
-        self::logdeb("garbage collection result = $result");
+        $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");
+        }
+
+        $session->free();
     }
 
     static function setSaveHandler()
diff --git a/scripts/sessiongc.php b/scripts/sessiongc.php
new file mode 100644 (file)
index 0000000..314b641
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env php
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, Control Yourself, 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$helptext = <<<END_OF_GC_HELP
+sessiongc.php
+
+Delete old sessions from the server
+
+END_OF_GC_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+$maxlifetime = ini_get('session.gc_maxlifetime');
+
+print "Deleting sessions older than $maxlifetime seconds.\n";
+
+Session::gc($maxlifetime);