aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggMetadata.php
diff options
context:
space:
mode:
authorEvan Winslow <evan@elgg.org>2012-10-09 20:57:20 -0700
committerEvan Winslow <evan@elgg.org>2012-10-09 20:57:20 -0700
commit7239da3fb83bbfdd414f96339ef33fee4d68554e (patch)
tree8a0be74b874fd142b81a44e935e36a5260093390 /engine/classes/ElggMetadata.php
parentca0f22f098bdac6982f30156884cf9f4c498c689 (diff)
parent61274b8cec92ee86dec24c99fd6ef180c1681ab2 (diff)
downloadelgg-7239da3fb83bbfdd414f96339ef33fee4d68554e.tar.gz
elgg-7239da3fb83bbfdd414f96339ef33fee4d68554e.tar.bz2
Merge pull request #377 from mrclay/4290-1.8
Fixes #4290: adds preloading volatile metadata cache and unit tests
Diffstat (limited to 'engine/classes/ElggMetadata.php')
-rw-r--r--engine/classes/ElggMetadata.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php
index 634a122e5..7f45dc3ea 100644
--- a/engine/classes/ElggMetadata.php
+++ b/engine/classes/ElggMetadata.php
@@ -26,8 +26,6 @@ class ElggMetadata extends ElggExtender {
* Construct a metadata object
*
* @param mixed $id ID of metadata or a database row as stdClass object
- *
- * @return void
*/
function __construct($id = null) {
$this->initializeAttributes();
@@ -54,7 +52,7 @@ class ElggMetadata extends ElggExtender {
*
* @param int $user_guid The GUID of the user (defaults to currently logged in user)
*
- * @return true|false Depending on permissions
+ * @return bool Depending on permissions
*/
function canEdit($user_guid = 0) {
if ($entity = get_entity($this->get('entity_guid'))) {
@@ -64,9 +62,11 @@ class ElggMetadata extends ElggExtender {
}
/**
- * Save matadata object
+ * Save metadata object
*
- * @return int the metadata object id
+ * @return int|bool the metadata object id or true if updated
+ *
+ * @throws IOException
*/
function save() {
if ($this->id > 0) {
@@ -89,7 +89,13 @@ class ElggMetadata extends ElggExtender {
* @return bool
*/
function delete() {
- return elgg_delete_metastring_based_object_by_id($this->id, 'metadata');
+ $success = elgg_delete_metastring_based_object_by_id($this->id, 'metadata');
+ if ($success) {
+ // we mark unknown here because this deletes only one value
+ // under this name, and there may be others remaining.
+ elgg_get_metadata_cache()->markUnknown($this->entity_guid, $this->name);
+ }
+ return $success;
}
/**
@@ -99,17 +105,27 @@ class ElggMetadata extends ElggExtender {
* @since 1.8
*/
function disable() {
- return elgg_set_metastring_based_object_enabled_by_id($this->id, 'no', 'metadata');
+ $success = elgg_set_metastring_based_object_enabled_by_id($this->id, 'no', 'metadata');
+ if ($success) {
+ // we mark unknown here because this disables only one value
+ // under this name, and there may be others remaining.
+ elgg_get_metadata_cache()->markUnknown($this->entity_guid, $this->name);
+ }
+ return $success;
}
/**
- * Disable the metadata
+ * Enable the metadata
*
* @return bool
* @since 1.8
*/
function enable() {
- return elgg_set_metastring_based_object_enabled_by_id($this->id, 'yes', 'metadata');
+ $success = elgg_set_metastring_based_object_enabled_by_id($this->id, 'yes', 'metadata');
+ if ($success) {
+ elgg_get_metadata_cache()->markUnknown($this->entity_guid, $this->name);
+ }
+ return $success;
}
/**