From e7439554222b46912702ad6041b2767c9411770b Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 1 Jul 2009 11:43:16 +0000 Subject: Metadata delete now passing correct object, also handles missing metadata entity. git-svn-id: https://code.elgg.org/elgg/trunk@3372 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metadata.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 79a5faacf..063188a47 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -355,15 +355,17 @@ $id = (int)$id; $metadata = get_metadata($id); - - // Tidy up if memcache is enabled. - static $metabyname_memcache; - if ((!$metabyname_memcache) && (is_memcache_available())) - $metabyname_memcache = new ElggMemcache('metabyname_memcache'); - if ($metabyname_memcache) $metabyname_memcache->delete("{$metadata->entity_guid}:{$metadata->name_id}"); - - if (($metadata->canEdit()) && (trigger_elgg_event('delete', 'metadata', $obj))) - return delete_data("DELETE from {$CONFIG->dbprefix}metadata where id=$id"); + + if ($metadata) { + // Tidy up if memcache is enabled. + static $metabyname_memcache; + if ((!$metabyname_memcache) && (is_memcache_available())) + $metabyname_memcache = new ElggMemcache('metabyname_memcache'); + if ($metabyname_memcache) $metabyname_memcache->delete("{$metadata->entity_guid}:{$metadata->name_id}"); + + if (($metadata->canEdit()) && (trigger_elgg_event('delete', 'metadata', $metadata))) + return delete_data("DELETE from {$CONFIG->dbprefix}metadata where id=$id"); + } return false; } -- cgit v1.2.3