]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Mathematical calculations on annotations will return false for non-existent entity...
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 2 Jun 2010 21:56:35 +0000 (21:56 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 2 Jun 2010 21:56:35 +0000 (21:56 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6334 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/annotations.php

index a956a95cc98f81cd8d04fd59906a3b38c9f7cd7c..13e7ed7902f2d58851dac2f7388920b3ea5da4f8 100644 (file)
@@ -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;