aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-13 15:20:42 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-13 15:20:42 +0000
commit9a0d66f6b02e8ef63051372b7ed64b5e3019a7b3 (patch)
tree4843a963b0788c2631a2cc652640e5f30e2fdcab
parent1708fa3e330894854f5bfea4d90cf07fb3bdc714 (diff)
downloadelgg-9a0d66f6b02e8ef63051372b7ed64b5e3019a7b3.tar.gz
elgg-9a0d66f6b02e8ef63051372b7ed64b5e3019a7b3.tar.bz2
Fixed update/insert issue on all top-level entities
git-svn-id: https://code.elgg.org/elgg/trunk@912 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/objects.php23
-rw-r--r--engine/lib/sites.php24
-rw-r--r--engine/lib/users.php24
3 files changed, 38 insertions, 33 deletions
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 1914744a6..7c14e8cee 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -235,17 +235,18 @@
if ($row)
{
// Core entities row exists and we have access to it
-
- $result = update_data("UPDATE {$CONFIG->dbprefix}objects_entity set title='$title', description='$description' 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}objects_entity where guid = {$guid}")) {
+ $result = update_data("UPDATE {$CONFIG->dbprefix}objects_entity set title='$title', description='$description' 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
{
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index 4d3de2794..c8636fdc8 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -268,17 +268,19 @@
if ($row)
{
- // Exists and you have access to it
- $result = update_data("UPDATE {$CONFIG->dbprefix}sites_entity set name='$name', description='$description', url='$url' 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);
- }
+ // Exists and you have access to it
+ if ($exists = get_data_row("select guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}")) {
+ $result = update_data("UPDATE {$CONFIG->dbprefix}sites_entity set name='$name', description='$description', url='$url' 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);
+ }
+ }
}
else
{
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
{