From 7d01d0bab8b077ed2367a823a1a8d25d676a43da Mon Sep 17 00:00:00 2001 From: nickw Date: Wed, 2 Jun 2010 21:56:35 +0000 Subject: Mathematical calculations on annotations will return false for non-existent entity subtypes. git-svn-id: http://code.elgg.org/elgg/trunk@6334 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index a956a95cc..13e7ed790 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -737,7 +737,14 @@ function __get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type $entity_type = sanitise_string($entity_type); $timeupper = (int)$timeupper; $timelower = (int)$timelower; - $entity_subtype = get_subtype_id($entity_type, $entity_subtype); + + if ($entity_subtype) { + if (!$entity_subtype = get_subtype_id($entity_type, $entity_subtype)) { + // requesting a non-existing subtype: return false + return FALSE; + } + } + if ($name != '' AND !$name = get_metastring_id($name)) { return 0; } @@ -830,7 +837,14 @@ function __get_entities_from_annotations_calculate_x($sum = "sum", $entity_type $sum = sanitise_string($sum); $entity_type = sanitise_string($entity_type); - $entity_subtype = get_subtype_id($entity_type, $entity_subtype); + + if ($entity_subtype) { + if (!$entity_subtype = get_subtype_id($entity_type, $entity_subtype)) { + // requesting a non-existing subtype: return false + return FALSE; + } + } + $name = get_metastring_id($name); $limit = (int) $limit; $offset = (int) $offset; -- cgit v1.2.3