diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-02-16 11:48:34 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-02-16 11:48:34 -0200 |
commit | b6ee1b93376d42f8a8fcee0127bc10f84d1e018e (patch) | |
tree | cbde5e4d0b745c3bb854c215bccea8b2d6bb367e /engine/classes/ElggSite.php | |
parent | 694306cf537fb8cb45beb7d4fd63c5b56cb5c4da (diff) | |
parent | 5aff5b3913fbb6226d8fb3162453c58888fba38d (diff) | |
download | elgg-b6ee1b93376d42f8a8fcee0127bc10f84d1e018e.tar.gz elgg-b6ee1b93376d42f8a8fcee0127bc10f84d1e018e.tar.bz2 |
Merge branch 'master' into saravea
Diffstat (limited to 'engine/classes/ElggSite.php')
-rw-r--r-- | engine/classes/ElggSite.php | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 401939005..1fe49b85c 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -117,37 +117,18 @@ class ElggSite extends ElggEntity { * @throws InvalidClassException */ protected function load($guid) { - // Test to see if we have the generic stuff - if (!parent::load($guid)) { - return false; - } - - // Only work with GUID from here - if ($guid instanceof stdClass) { - $guid = $guid->guid; - } - - // Check the type - if ($this->attributes['type'] != 'site') { - $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class())); - throw new InvalidClassException($msg); - } + $attr_loader = new ElggAttributeLoader(get_class(), 'site', $this->attributes); + $attr_loader->requires_access_control = !($this instanceof ElggPlugin); + $attr_loader->secondary_loader = 'get_site_entity_as_row'; - // Load missing data - $row = get_site_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; } @@ -381,6 +362,11 @@ class ElggSite extends ElggEntity { public function checkWalledGarden() { global $CONFIG; + // command line calls should not invoke the walled garden check + if (PHP_SAPI === 'cli') { + return; + } + if ($CONFIG->walled_garden) { if ($CONFIG->default_access == ACCESS_PUBLIC) { $CONFIG->default_access = ACCESS_LOGGED_IN; |