diff options
author | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-02 21:56:35 +0000 |
---|---|---|
committer | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-02 21:56:35 +0000 |
commit | 7d01d0bab8b077ed2367a823a1a8d25d676a43da (patch) | |
tree | 080623040eea16a3a7e06218fd19c33765ef3a87 /engine | |
parent | 2c5c43f9a632b05d5557f980e83bcecdd3f1332a (diff) | |
download | elgg-7d01d0bab8b077ed2367a823a1a8d25d676a43da.tar.gz elgg-7d01d0bab8b077ed2367a823a1a8d25d676a43da.tar.bz2 |
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
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/annotations.php | 18 |
1 files 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; |