aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggUser.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-12-17 07:12:01 -0800
committerBrett Profitt <brett.profitt@gmail.com>2012-12-17 07:12:01 -0800
commitb538cc3339ff886e309feb318cdea374423d1683 (patch)
tree14904c1de72d83398faa12dd19c4a87bf9a4e866 /engine/classes/ElggUser.php
parent4aae9078525de7c6e56091d6864e7397b58280cb (diff)
parent33c786c1b7838d38e9797b8731d4e45c9ceb1aac (diff)
downloadelgg-b538cc3339ff886e309feb318cdea374423d1683.tar.gz
elgg-b538cc3339ff886e309feb318cdea374423d1683.tar.bz2
Merge pull request #446 from mrclay/4929-18-entitiesopt
Fixes #4929: Optimize elgg_get_entities and add attribute loader
Diffstat (limited to 'engine/classes/ElggUser.php')
-rw-r--r--engine/classes/ElggUser.php36
1 files changed, 8 insertions, 28 deletions
diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php
index d7bb89265..6c1cdc1de 100644
--- a/engine/classes/ElggUser.php
+++ b/engine/classes/ElggUser.php
@@ -106,37 +106,17 @@ class ElggUser 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(), 'user', $this->attributes);
+ $attr_loader->secondary_loader = 'get_user_entity_as_row';
- // Only work with GUID from here
- if ($guid instanceof stdClass) {
- $guid = $guid->guid;
- }
-
- // Check the type
- if ($this->attributes['type'] != 'user') {
- $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));
- throw new InvalidClassException($msg);
- }
-
- // Load missing data
- $row = get_user_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;
}