]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #5600: Entities are kept out of entity cache during save
authorSteve Clay <steve@mrclay.org>
Fri, 7 Jun 2013 13:52:48 +0000 (09:52 -0400)
committerSteve Clay <steve@mrclay.org>
Fri, 7 Jun 2013 13:52:48 +0000 (09:52 -0400)
engine/classes/ElggEntity.php
engine/classes/ElggGroup.php
engine/classes/ElggObject.php
engine/classes/ElggUser.php

index 8b3ceb5511809d608c5118a96e847cc4f7d553d6..dd1c7c11430da5e8105d87d834ac9810dbc12266 100644 (file)
@@ -1270,15 +1270,23 @@ abstract class ElggEntity extends ElggData implements
        public function save() {
                $guid = $this->getGUID();
                if ($guid > 0) {
-                       _elgg_cache_entity($this);
 
-                       return update_entity(
+                       // See #5600. This ensures the lower level can_edit_entity() check will use a
+                       // fresh entity from the DB so it sees the persisted owner_guid
+                       _elgg_disable_caching_for_entity($guid);
+
+                       $ret = update_entity(
                                $guid,
                                $this->get('owner_guid'),
                                $this->get('access_id'),
                                $this->get('container_guid'),
                                $this->get('time_created')
                        );
+
+                       _elgg_enable_caching_for_entity($guid);
+                       _elgg_cache_entity($this);
+
+                       return $ret;
                } else {
                        // Create a new entity (nb: using attribute array directly
                        // 'cos set function does something special!)
index 61f9163d5302a1032d37d2851912f22572c7d2f5..7e69b7a8433a9bd5580580d1e190133e50fa63aa 100644 (file)
@@ -352,7 +352,12 @@ class ElggGroup extends ElggEntity
                }
 
                // Now save specific stuff
-               return create_group_entity($this->get('guid'), $this->get('name'), $this->get('description'));
+
+               _elgg_disable_caching_for_entity($this->guid);
+               $ret = create_group_entity($this->get('guid'), $this->get('name'), $this->get('description'));
+               _elgg_enable_caching_for_entity($this->guid);
+
+               return $ret;
        }
 
        // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////
index d54752dca5d32614f54f51638d54830ece976699..aeaa3ba5c2ae40ec7898195d1d24855c22dd8fbd 100644 (file)
@@ -126,8 +126,12 @@ class ElggObject extends ElggEntity {
                }
 
                // Save ElggObject-specific attributes
-               return create_object_entity($this->get('guid'), $this->get('title'),
-                       $this->get('description'));
+
+               _elgg_disable_caching_for_entity($this->guid);
+               $ret = create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'));
+               _elgg_enable_caching_for_entity($this->guid);
+
+               return $ret;
        }
 
        /**
index b2cada8ef471cd24b147b4dad1ed6855d35e7aa7..6163f9b62c5f50b5f77d60ff6121148aa0c445a0 100644 (file)
@@ -132,9 +132,13 @@ class ElggUser extends ElggEntity
                }
 
                // Now save specific stuff
-               return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'),
+               _elgg_disable_caching_for_entity($this->guid);
+               $ret = create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'),
                        $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'),
                        $this->get('code'));
+               _elgg_enable_caching_for_entity($this->guid);
+
+               return $ret;
        }
 
        /**