[Fusionforge-commits] r8382 - trunk/gforge/common/include

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Nov 18 17:29:35 CET 2009


Author: lolando
Date: 2009-11-18 17:29:35 +0100 (Wed, 18 Nov 2009)
New Revision: 8382

Modified:
   trunk/gforge/common/include/session.php
Log:
Don't try to insert a new session if it would break a unique constraint (which can happen if automated processes establish several sessions in quick succession)

Modified: trunk/gforge/common/include/session.php
===================================================================
--- trunk/gforge/common/include/session.php	2009-11-18 16:18:15 UTC (rev 8381)
+++ trunk/gforge/common/include/session.php	2009-11-18 16:29:35 UTC (rev 8382)
@@ -399,11 +399,15 @@
 	session_cookie("session_ser", $cookie, "", $GLOBALS['sys_session_expire']);
 	$session_ser=$cookie;
 
-	db_query_params ('INSERT INTO user_session (session_hash,ip_addr,time,user_id) VALUES ($1,$2,$3,$4)',
-			 array (session_get_session_cookie_hash($cookie),
-				getStringFromServer('REMOTE_ADDR'),
-				time(),
-				$user_id)) ;
+	$res = db_query_params ('SELECT count(*) FROM user_session WHERE session_hash = $1',
+				array (session_get_session_cookie_hash($cookie))) ;
+	if (!$res || db_numrows($res) < 1) {
+		db_query_params ('INSERT INTO user_session (session_hash,ip_addr,time,user_id) VALUES ($1,$2,$3,$4)',
+				 array (session_get_session_cookie_hash($cookie),
+					getStringFromServer('REMOTE_ADDR'),
+					time(),
+					$user_id)) ;
+	}
 
 	// check uniqueness of the session_hash in the database
 	// 




More information about the Fusionforge-commits mailing list