aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/classes/ElggAnnotation.php14
-rw-r--r--engine/classes/ElggMetadata.php4
-rw-r--r--engine/lib/annotations.php4
3 files changed, 11 insertions, 11 deletions
diff --git a/engine/classes/ElggAnnotation.php b/engine/classes/ElggAnnotation.php
index 30d9c4245..78d29ee7f 100644
--- a/engine/classes/ElggAnnotation.php
+++ b/engine/classes/ElggAnnotation.php
@@ -28,26 +28,26 @@ class ElggAnnotation extends ElggExtender {
}
/**
- * Construct a new annotation, optionally from a given id value or db object.
+ * Construct a new annotation object
*
- * @param mixed $id The annotation ID
+ * @param mixed $id The annotation ID or a database row as stdClass object
*/
function __construct($id = null) {
$this->initializeAttributes();
if (!empty($id)) {
+ // Create from db row
if ($id instanceof stdClass) {
$annotation = $id;
- } else {
- $annotation = elgg_get_annotation_from_id($id);
- }
- if ($annotation) {
$objarray = (array) $annotation;
-
foreach ($objarray as $key => $value) {
$this->attributes[$key] = $value;
}
+ } else {
+ // get an ElggAnnotation object and copy its attributes
+ $annotation = elgg_get_annotation_from_id($id);
+ $this->attributes = $annotation->attributes;
}
}
}
diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php
index 135c17028..ed3f8614f 100644
--- a/engine/classes/ElggMetadata.php
+++ b/engine/classes/ElggMetadata.php
@@ -16,9 +16,9 @@ class ElggMetadata extends ElggExtender {
}
/**
- * Construct a new site object, optionally from a given id value or row.
+ * Construct a metadata object
*
- * @param mixed $id ID of metadata from DB
+ * @param mixed $id ID of metadata or a database row as stdClass object
*
* @return void
*/
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 0e446c949..1178a079f 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -158,8 +158,8 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu
// If ok then add it
$result = update_data("UPDATE {$CONFIG->dbprefix}annotations
- set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid
- where id=$annotation_id and name_id='$name' and $access");
+ set name_id='$name', value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid
+ where id=$annotation_id and $access");
if ($result !== false) {
$obj = elgg_get_annotation_from_id($annotation_id);