diff options
author | Steve Clay <steve@mrclay.org> | 2012-11-26 01:17:39 -0500 |
---|---|---|
committer | Steve Clay <steve@mrclay.org> | 2012-11-26 16:01:50 -0500 |
commit | 33c786c1b7838d38e9797b8731d4e45c9ceb1aac (patch) | |
tree | 14d0e21d0ce67939a4483ec1cf0feaccfed09780 /engine/classes/ElggGroup.php | |
parent | 19c6da97ed0178592b9041946f3463f9008dd7ea (diff) | |
download | elgg-33c786c1b7838d38e9797b8731d4e45c9ceb1aac.tar.gz elgg-33c786c1b7838d38e9797b8731d4e45c9ceb1aac.tar.bz2 |
Fixes #4929: Optimize elgg_get_entities and add attribute loader
Diffstat (limited to 'engine/classes/ElggGroup.php')
-rw-r--r-- | engine/classes/ElggGroup.php | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 121186196..ea257f368 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -324,37 +324,18 @@ class ElggGroup extends ElggEntity * @return bool */ protected function load($guid) { - // Test to see if we have the generic stuff - if (!parent::load($guid)) { - return false; - } + $attr_loader = new ElggAttributeLoader(get_class(), 'group', $this->attributes); + $attr_loader->requires_access_control = !($this instanceof ElggPlugin); + $attr_loader->secondary_loader = 'get_group_entity_as_row'; - // Only work with GUID from here - if ($guid instanceof stdClass) { - $guid = $guid->guid; - } - - // Check the type - if ($this->attributes['type'] != 'group') { - $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); - throw new InvalidClassException($msg); - } - - // Load missing data - $row = get_group_entity_as_row($guid); - if (($row) && (!$this->isFullyLoaded())) { - // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded']++; - } - - // Now put these into the attributes array as core values - $objarray = (array) $row; - foreach ($objarray as $key => $value) { - $this->attributes[$key] = $value; + $attrs = $attr_loader->getRequiredAttributes($guid); + if (!$attrs) { + return false; } - // guid needs to be an int http://trac.elgg.org/ticket/4111 - $this->attributes['guid'] = (int)$this->attributes['guid']; + $this->attributes = $attrs; + $this->attributes['tables_loaded'] = 2; + cache_entity($this); return true; } |