From 915bdaf8fb2c69395fd0371e5a3d6cb47c367cb4 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 19 Jun 2008 18:51:00 +0000 Subject: System_log no longer adds double entries. git-svn-id: https://code.elgg.org/elgg/trunk@1007 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/system_log.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php index d35453c68..52ec6bee0 100644 --- a/engine/lib/system_log.php +++ b/engine/lib/system_log.php @@ -99,10 +99,14 @@ */ function system_log($object, $event) { - global $CONFIG; + global $CONFIG; + static $logcache; if ($object instanceof Loggable) - { + { + + if (!is_array($logcache)) $logcache = array(); + // Has loggable interface, extract the necessary information and store $object_id = (int)$object->getSystemLogID(); $object_class = $object->getClassName(); @@ -110,8 +114,17 @@ $time = time(); $performed_by = (int)$_SESSION['guid']; - // Create log - return insert_data("INSERT into {$CONFIG->dbprefix}system_log (object_id, object_class, event, performed_by_guid, time_created) VALUES ('$object_id','$object_class','$event',$performed_by, '$time')"); + // Create log if we haven't already created it + if (!isset($logcache[$time][$object_id][$event])) { + if (insert_data("INSERT into {$CONFIG->dbprefix}system_log (object_id, object_class, event, performed_by_guid, time_created) VALUES ('$object_id','$object_class','$event',$performed_by, '$time')")) { + $logcache[$time][$object_id][$event] = true; + return true; + } + return false; + } + + return true; + } } -- cgit v1.2.3