From 146062199ca57fdf34ff3a7acc603c63b644e290 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 8 Apr 2008 16:48:35 +0000 Subject: Incorporating setup fixes from Rolando git-svn-id: https://code.elgg.org/elgg/trunk@423 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'engine/lib/users.php') diff --git a/engine/lib/users.php b/engine/lib/users.php index cdd7f9a3d..68383d8e5 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -58,7 +58,7 @@ // Is $guid is a DB row - either a entity row, or a user table row. if ($guid instanceof stdClass) { // Load the rest - if (!$this->load($guid->guid)) + if (!$this->load($guid->guid)) throw new IOException("Failed to load new ElggUser from GUID:$guid->guid"); } @@ -261,7 +261,7 @@ public function getCollections($subtype="", $limit = 10, $offset = 0) { return get_user_collections($this->getGUID(), $subtype, $limit, $offset); } } - + /** * Return the user specific details of a user by a row. * @@ -417,27 +417,28 @@ $ntt = get_entities('object',$subtype, $user_guid, "time_created desc", $limit, $offset); return $ntt; } - - /** - * Get a user object from a GUID. - * - * This function returns an ElggUser from a given GUID. - * @param int $guid The GUID - * @return ElggUser|false - * @throws InvalidParameterException if $GUID exists but is not an ElggUser. - */ - function get_user($guid) - { - $result = get_entity($guid); - - if (($result) && (!($result instanceof ElggUser))) - throw new InvalidParameterException("GUID:$guid is not an ElggUser"); - - if ($result) - return $result; - - return false; - } + + /** + * Get a user object from a GUID. + * + * This function returns an ElggUser from a given GUID. + * @param int $guid The GUID + * @return ElggUser|false + * @throws InvalidParameterException if $GUID exists but is not an ElggUser. + */ + function get_user($guid) + { + if (!empty($guid)) // Fixes "Exception thrown without stack frame" when db_select fails + $result = get_entity($guid); + + if (($result) && (!($result instanceof ElggUser))) + throw new InvalidParameterException("GUID:$guid is not an ElggUser"); + + if ($result) + return $result; + + return false; + } /** * Get user by username @@ -474,7 +475,7 @@ return new ElggUser($row); return false; - } + } /** * Registers a user, returning false if the username already exists -- cgit v1.2.3