aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/objects.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/objects.php')
-rw-r--r--engine/lib/objects.php43
1 files changed, 28 insertions, 15 deletions
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index e44a005ff..b14e984c0 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -217,22 +217,35 @@
$row = get_entity_as_row($guid);
if ($row)
- {
- // Exists and you have access to it
-
- // Delete any existing stuff
- delete_object_entity($guid);
-
- // Insert it
- $result = insert_data("INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title','$description')");
- if ($result!==false) {
- $entity = get_entity($guid);
- if (trigger_event('create',$entity->type,$entity)) {
- return true;
- } else {
- delete_entity($guid);
- }
+ {
+ // 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_event('update',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
+ else
+ {
+
+ // Update failed, attempt an insert.
+ $result = insert_data("INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title','$description')");
+ if ($result!==false) {
+ $entity = get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
}
+
}
return false;