From 9a0d66f6b02e8ef63051372b7ed64b5e3019a7b3 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 13 Jun 2008 15:20:42 +0000 Subject: Fixed update/insert issue on all top-level entities git-svn-id: https://code.elgg.org/elgg/trunk@912 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'engine/lib/users.php') diff --git a/engine/lib/users.php b/engine/lib/users.php index fd5011c9e..5065a633a 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -363,17 +363,19 @@ if ($row) { // Exists and you have access to it - - $result = update_data("UPDATE {$CONFIG->dbprefix}users_entity set name='$name', username='$username', password='$password', email='$email', language='$language', code='$code', last_action = ". time() ." where guid = {$guid}"); - if ($result != false) - { - // Update succeeded, continue - $entity = get_entity($guid); - if (trigger_elgg_event('update',$entity->type,$entity)) { - return true; - } else { - delete_entity($guid); - } + + if ($exists = get_data_row("select guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}")) { + $result = update_data("UPDATE {$CONFIG->dbprefix}users_entity set name='$name', username='$username', password='$password', email='$email', language='$language', code='$code', last_action = ". time() ." where guid = {$guid}"); + if ($result != false) + { + // Update succeeded, continue + $entity = get_entity($guid); + if (trigger_elgg_event('update',$entity->type,$entity)) { + return true; + } else { + $entity->delete(); + } + } } else { -- cgit v1.2.3