aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-12 23:37:29 +0000
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-12 23:37:29 +0000
commit014ba7d5c18172db7ff6940df12f0a785c9acbdb (patch)
tree36c5a1cf0c42feac25e19b3c3ab550b7fcfe9244 /engine/lib
parentb95f23779af7f11a622a0e978c4a5a0917b8c76e (diff)
downloadelgg-014ba7d5c18172db7ff6940df12f0a785c9acbdb.tar.gz
elgg-014ba7d5c18172db7ff6940df12f0a785c9acbdb.tar.bz2
Updating ElggEntity::clearMetaData() to fail when passed a non-existent metadata name.
Fixes #2273 git-svn-id: http://code.elgg.org/elgg/trunk@7301 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/metadata.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index ffa7b74e0..8b6fe364f 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -60,12 +60,19 @@ function remove_metadata($entity_guid, $name, $value = "") {
$entity_guid = (int) $entity_guid;
$name = sanitise_string($name);
$value = sanitise_string($value);
+
+ $name = get_metastring_id($name);
+ if ($name === FALSE) {
+ // name doesn't exist
+ return FALSE;
+ }
- $query = "SELECT * from {$CONFIG->dbprefix}metadata"
- . " WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name);
-
+ $query = "SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = '$entity_guid' and name_id = '$name'";
if ($value != "") {
- $query .= " and value_id=" . add_metastring($value);
+ $value = get_metastring_id($value);
+ if ($value !== FALSE) {
+ $query .= " AND value_id = '$value'";
+ }
}
if ($existing = get_data($query)) {