aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Bakker <jeabakker@coldtrick.com>2013-12-02 14:56:20 +0100
committerJerome Bakker <jeabakker@coldtrick.com>2013-12-02 14:56:20 +0100
commit908628e622d798c5036f7e25bc5b7d6d36d64754 (patch)
treee12dc92e26c2ee734d480ec6d9321f49e943b14b
parent47f209929b1913a73b8051d35d5545d28a37dba7 (diff)
downloadelgg-908628e622d798c5036f7e25bc5b7d6d36d64754.tar.gz
elgg-908628e622d798c5036f7e25bc5b7d6d36d64754.tar.bz2
fixes #3143 login part
-rw-r--r--engine/lib/memcache.php20
-rw-r--r--engine/lib/sessions.php6
2 files changed, 26 insertions, 0 deletions
diff --git a/engine/lib/memcache.php b/engine/lib/memcache.php
index f79fba4..79b87e8 100644
--- a/engine/lib/memcache.php
+++ b/engine/lib/memcache.php
@@ -35,3 +35,23 @@ function is_memcache_available() {
return $memcache_available;
}
+
+/**
+ * Invalidate an entity in memcache
+ *
+ * @param int $entity_guid The GUID of the entity to invalidate
+ *
+ * @return void
+ * @access private
+ */
+function _elgg_invalidate_memcache_for_entity($entity_guid) {
+ static $newentity_cache;
+
+ if ((!$newentity_cache) && (is_memcache_available())) {
+ $newentity_cache = new ElggMemcache('new_entity_cache');
+ }
+
+ if ($newentity_cache) {
+ $newentity_cache->delete($entity_guid);
+ }
+} \ No newline at end of file
diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php
index fb28e1e..e3d5ce9 100644
--- a/engine/lib/sessions.php
+++ b/engine/lib/sessions.php
@@ -326,6 +326,12 @@ function login(ElggUser $user, $persistent = false) {
set_last_login($_SESSION['guid']);
reset_login_failure_count($user->guid); // Reset any previous failed login attempts
+ // if memcache is enabled, invalidate the user in memcache @see https://github.com/Elgg/Elgg/issues/3143
+ if (is_memcache_available()) {
+ // this needs to happen with a shutdown function because of the timing with set_last_login()
+ register_shutdown_function("_elgg_invalidate_memcache_for_entity", $_SESSION['guid']);
+ }
+
return true;
}