aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authorEvan Winslow <evan@elgg.org>2012-10-09 20:40:52 -0700
committerEvan Winslow <evan@elgg.org>2012-10-09 20:40:52 -0700
commit84bf48937a7b294649701c1d6f4553dc0aeb4cd7 (patch)
treea81619785c453aa1a2ba212fcbed0c1233315942 /engine/lib/entities.php
parentf0b6ec93e6fea5ee5215887c6f4fca9bad56302e (diff)
parent5c069bbca76fb8519548b2c8df2b9b6f3b3885b0 (diff)
downloadelgg-84bf48937a7b294649701c1d6f4553dc0aeb4cd7.tar.gz
elgg-84bf48937a7b294649701c1d6f4553dc0aeb4cd7.tar.bz2
Merge pull request #399 from mrclay/3018-memcache-access
Fixes #3018: Checks DB for access before using memcache-stored entity
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 3896cd58f..7122974dd 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -698,7 +698,7 @@ function get_entity($guid) {
// but that evaluates to a false positive for $guid = TRUE.
// This is a bit slower, but more thorough.
if (!is_numeric($guid) || $guid === 0 || $guid === '0') {
- return FALSE;
+ return false;
}
// Check local cache first
@@ -715,14 +715,23 @@ function get_entity($guid) {
$shared_cache = false;
}
}
+
+ // until ACLs in memcache, DB query is required to determine access
+ $entity_row = get_entity_as_row($guid);
+ if (!$entity_row) {
+ return false;
+ }
+
if ($shared_cache) {
- $new_entity = $shared_cache->load($guid);
- if ($new_entity) {
- return $new_entity;
+ $cached_entity = $shared_cache->load($guid);
+ // @todo store ACLs in memcache http://trac.elgg.org/ticket/3018#comment:3
+ if ($cached_entity) {
+ // @todo use ACL and cached entity access_id to determine if user can see it
+ return $cached_entity;
}
}
- $new_entity = entity_row_to_elggstar(get_entity_as_row($guid));
+ $new_entity = entity_row_to_elggstar($entity_row);
if ($new_entity) {
cache_entity($new_entity);
}