aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-11-28 16:06:44 -0500
committerSteve Clay <steve@mrclay.org>2012-11-28 16:06:44 -0500
commit7f8354496e76a4de6c73b7ee5e27061b2fec6143 (patch)
treef814784096c38f0e2d790691c8812e92f0152116
parentd87c0ce422debe2a5b986a55b66c4b804c4b5927 (diff)
parent87b2da7e3d8f06ba541fea29d44c4c2e9630584d (diff)
downloadelgg-7f8354496e76a4de6c73b7ee5e27061b2fec6143.tar.gz
elgg-7f8354496e76a4de6c73b7ee5e27061b2fec6143.tar.bz2
Merge branch '4937-18-md' into 1.8
-rw-r--r--engine/lib/entities.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index a1c1c2997..e9c96a596 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -68,7 +68,15 @@ function cache_entity(ElggEntity $entity) {
// Don't store too many or we'll have memory problems
// TODO(evan): Pick a less arbitrary limit
if (count($ENTITY_CACHE) > 256) {
- unset($ENTITY_CACHE[array_rand($ENTITY_CACHE)]);
+ $random_guid = array_rand($ENTITY_CACHE);
+
+ unset($ENTITY_CACHE[$random_guid]);
+
+ // Purge separate metadata cache. Original idea was to do in entity destructor, but that would
+ // have caused a bunch of unnecessary purges at every shutdown. Doing it this way we have no way
+ // to know that the expunged entity will be GCed (might be another reference living), but that's
+ // OK; the metadata will reload if necessary.
+ elgg_get_metadata_cache()->clear($random_guid);
}
$ENTITY_CACHE[$entity->guid] = $entity;