aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2013-06-08 22:12:12 -0400
committerSteve Clay <steve@mrclay.org>2013-06-08 22:12:12 -0400
commit5a1a793f8634e0f7133644e09e9ace60782864d4 (patch)
tree7fe6331e9866352d605b32c16f0e0ba56651273a /engine
parent8dbdf2f72c9dccbbd471e805fbd112c6817cdcec (diff)
downloadelgg-5a1a793f8634e0f7133644e09e9ace60782864d4.tar.gz
elgg-5a1a793f8634e0f7133644e09e9ace60782864d4.tar.bz2
Fixes #5598: Properly update metadata cache in update_metadata()
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/metadata.php10
-rw-r--r--engine/tests/api/metadata_cache.php7
2 files changed, 12 insertions, 5 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 43f7d5d6e..046b85124 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -191,19 +191,19 @@ function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_i
}
// Add the metastring
- $value = add_metastring($value);
- if (!$value) {
+ $value_id = add_metastring($value);
+ if (!$value_id) {
return false;
}
- $name = add_metastring($name);
- if (!$name) {
+ $name_id = add_metastring($name);
+ if (!$name_id) {
return false;
}
// If ok then add it
$query = "UPDATE {$CONFIG->dbprefix}metadata"
- . " set name_id='$name', value_id='$value', value_type='$value_type', access_id=$access_id,"
+ . " set name_id='$name_id', value_id='$value_id', value_type='$value_type', access_id=$access_id,"
. " owner_guid=$owner_guid where id=$id";
$result = update_data($query);
diff --git a/engine/tests/api/metadata_cache.php b/engine/tests/api/metadata_cache.php
index 846116a7b..7fb328169 100644
--- a/engine/tests/api/metadata_cache.php
+++ b/engine/tests/api/metadata_cache.php
@@ -166,4 +166,11 @@ class ElggCoreMetadataCacheTest extends ElggCoreUnitTest {
$actual = $this->cache->filterMetadataHeavyEntities($guids, 6000);
$this->assertIdentical($actual, $expected);
}
+
+ public function testCreateMetadataInvalidates() {
+ $this->obj1->foo = 1;
+ create_metadata($this->guid1, 'foo', 2, '', elgg_get_logged_in_user_guid(), ACCESS_FRIENDS);
+
+ $this->assertEqual($this->obj1->foo, 2);
+ }
}