aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-17 11:32:54 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-17 11:32:54 +0000
commit3742b2c835d6e025b9fef95de921eb1dc5e28b5a (patch)
tree20d5a7a492476d1c6929674d66ad94c90a466185 /engine/lib
parent2b02c1df3e004e270301fa8c630949bc557b0ee9 (diff)
downloadelgg-3742b2c835d6e025b9fef95de921eb1dc5e28b5a.tar.gz
elgg-3742b2c835d6e025b9fef95de921eb1dc5e28b5a.tar.bz2
Refs #3154 adding system log cache bug fix to trunk
git-svn-id: http://code.elgg.org/elgg/trunk@8753 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/system_log.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php
index 61b386353..d6c746af1 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -154,11 +154,14 @@ function get_object_from_log_entry($entry_id) {
*/
function system_log($object, $event) {
global $CONFIG;
- static $logcache;
+ static $log_cache;
+ static $cache_size = 0;
if ($object instanceof Loggable) {
- if (!is_array($logcache)) {
- $logcache = array();
+ // reset cache if it has grown too large
+ if (!is_array($log_cache) || $cache_size > 500) {
+ $log_cache = array();
+ $cache_size = 0;
}
// Has loggable interface, extract the necessary information and store
@@ -188,7 +191,7 @@ function system_log($object, $event) {
}
// Create log if we haven't already created it
- if (!isset($logcache[$time][$object_id][$event])) {
+ if (!isset($log_cache[$time][$object_id][$event])) {
$query = "INSERT DELAYED into {$CONFIG->dbprefix}system_log
(object_id, object_class, object_type, object_subtype, event,
performed_by_guid, owner_guid, access_id, enabled, time_created)
@@ -198,7 +201,8 @@ function system_log($object, $event) {
insert_data($query);
- $logcache[$time][$object_id][$event] = true;
+ $log_cache[$time][$object_id][$event] = true;
+ $cache_size += 1;
}
return true;