[phpBB] svn: r381 - in trunk/phpbb2: . patches

kink at wolffelaar.nl kink at wolffelaar.nl
Thu May 31 19:09:58 CEST 2007


Author: kink
Date: 2007-05-31 19:09:57 +0200 (Thu, 31 May 2007)
New Revision: 381

Added:
   trunk/phpbb2/patches/031_delete_oldest_from_session_table.diff
Modified:
   trunk/phpbb2/changelog
Log:
Automatically delete oldest sessions when session table is full.


Modified: trunk/phpbb2/changelog
===================================================================
--- trunk/phpbb2/changelog	2007-05-31 17:03:52 UTC (rev 380)
+++ trunk/phpbb2/changelog	2007-05-31 17:09:57 UTC (rev 381)
@@ -5,8 +5,10 @@
   * Install the search_time attribute in phpbb_search_results when it
     does not exist yet (Closes: #414684, #423798).
   * Install a ranks dir under /var/lib/phpbb2 (Closes: #421392).
+  * Automatically delete oldest sessions when session table is full.
+    Thanks Christer Mjellem Strand for the patch (Closes: #419441).
 
- -- Thijs Kinkhorst <thijs at debian.org>  Thu, 31 May 2007 19:00:44 +0200
+ -- Thijs Kinkhorst <thijs at debian.org>  Thu, 31 May 2007 19:09:08 +0200
 
 phpbb2 (2.0.22-1) unstable; urgency=low
 

Added: trunk/phpbb2/patches/031_delete_oldest_from_session_table.diff
===================================================================
--- trunk/phpbb2/patches/031_delete_oldest_from_session_table.diff	2007-05-31 17:03:52 UTC (rev 380)
+++ trunk/phpbb2/patches/031_delete_oldest_from_session_table.diff	2007-05-31 17:09:57 UTC (rev 381)
@@ -0,0 +1,40 @@
+--- phpBB2/includes/sessions.old	2007-01-18 00:35:40.000000000 +0100
++++ phpBB2/includes/sessions.php	2007-04-15 18:54:09.000000000 +0200
+@@ -186,7 +186,36 @@
+ 			VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login)";
+ 		if ( !$db->sql_query($sql) )
+ 		{
+-			message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
++			$error = TRUE; 
++			if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4") 
++			{ 
++			    $sql_error = $db->sql_error($result); 
++			    if ($sql_error["code"] == 1114) 
++			    { 
++			        $result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"'); 
++			        $row = $db->sql_fetchrow($result); 
++			        if ($row["Type"] == "HEAP") 
++			        { 
++			            if ($row["Rows"] > 2500) 
++			            { 
++			                $delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : ""; 
++			                $db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50"); 
++			            } 
++			            else 
++			            { 
++			                $db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50)); 
++			            } 
++			            if ($db->sql_query($sql)) 
++			            { 
++			                $error = FALSE; 
++			            } 
++			        } 
++			    } 
++			} 
++			if ($error) 
++			{ 
++			    message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql); 
++			}
+ 		}
+ 	}
+ 





More information about the phpBB-l mailing list