From 33c786c1b7838d38e9797b8731d4e45c9ceb1aac Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 26 Nov 2012 01:17:39 -0500 Subject: Fixes #4929: Optimize elgg_get_entities and add attribute loader --- engine/classes/ElggSite.php | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'engine/classes/ElggSite.php') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 401939005..f7f5b68ea 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; - } + $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'; - // 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); - } - - // 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; } -- cgit v1.2.3 From 718cddc89e3b4901a641e175e86b4208436f2089 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 20 Jan 2013 20:32:33 -0500 Subject: Fixes #4991 CLI allowed when walled garden is turned on --- CHANGES.txt | 8 ++++++-- engine/classes/ElggSite.php | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'engine/classes/ElggSite.php') diff --git a/CHANGES.txt b/CHANGES.txt index 8687b3d2a..105d60f72 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,12 +2,16 @@ Version 1.8.13 (January xx, 2013 from https://github.com/Elgg/Elgg/tree/1.8) Contributing Developers: * Cash Costello - * Cristo Rabani + * Kevin Jardine + * Krzysztof Różalski Security Fixes: + Bugfixes: + * CLI usages with walled garden fixed + Enhancements: - * Added confirm dialog for resetting profile fields (adds language string profile:resetdefault:confirm) + * Added confirm dialog for resetting profile fields (adds language string profile:resetdefault:confirm) Version 1.8.12 diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index f7f5b68ea..1fe49b85c 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -362,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; -- cgit v1.2.3