]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
fixes #3143 login part
authorJerome Bakker <jeabakker@coldtrick.com>
Mon, 2 Dec 2013 13:56:20 +0000 (14:56 +0100)
committerJerome Bakker <jeabakker@coldtrick.com>
Mon, 2 Dec 2013 13:56:20 +0000 (14:56 +0100)
engine/lib/memcache.php
engine/lib/sessions.php

index f79fba4a9f71bdeff9bd4d5f85ab47f035e572b6..79b87e8500750d77d339ba75026925eb753d47b8 100644 (file)
@@ -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;
+       \r
+       if ((!$newentity_cache) && (is_memcache_available())) {\r
+               $newentity_cache = new ElggMemcache('new_entity_cache');\r
+       }
+       \r
+       if ($newentity_cache) {\r
+               $newentity_cache->delete($entity_guid);\r
+       }
+}
\ No newline at end of file
index fb28e1e9ad71dda073f07c175e9db8977d0c3431..e3d5ce9cd5e445a163c0868e648aad373d292650 100644 (file)
@@ -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;
 }