]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3713. elgg_get_entities() and friends return false if passed invalid options.
authorBrett Profitt <brett.profitt@gmail.com>
Thu, 29 Sep 2011 05:05:31 +0000 (22:05 -0700)
committerBrett Profitt <brett.profitt@gmail.com>
Thu, 29 Sep 2011 05:05:31 +0000 (22:05 -0700)
engine/lib/entities.php
engine/lib/metastrings.php
engine/lib/river.php
engine/lib/tags.php
engine/tests/api/entity_getter_functions.php

index cea8af1da243e6c7caec069e15c7d68d92b40a39..abf7395e751e6861df4dfbbac6c3589fad08001f 100644 (file)
@@ -846,9 +846,6 @@ function elgg_get_entities(array $options = array()) {
        $wheres[] = elgg_get_entity_time_where_sql('e', $options['created_time_upper'],
                $options['created_time_lower'], $options['modified_time_upper'], $options['modified_time_lower']);
 
-       // remove identical where clauses
-       $wheres = array_unique($wheres);
-
        // see if any functions failed
        // remove empty strings on successful functions
        foreach ($wheres as $i => $where) {
@@ -859,6 +856,9 @@ function elgg_get_entities(array $options = array()) {
                }
        }
 
+       // remove identical where clauses
+       $wheres = array_unique($wheres);
+
        // evaluate join clauses
        if (!is_array($options['joins'])) {
                $options['joins'] = array($options['joins']);
index d444121d0ebbd4000ede71216b0be5b90c4becef..8c00fb2ad0a9d6e9e24fff853b7ab63e2b4b6544 100644 (file)
@@ -360,9 +360,6 @@ function elgg_get_metastring_based_objects($options) {
        $wheres[] = elgg_get_guid_based_where_sql('n_table.owner_guid',
                $options['metastring_owner_guids']);
 
-       // remove identical where clauses
-       $wheres = array_unique($wheres);
-
        // see if any functions failed
        // remove empty strings on successful functions
        foreach ($wheres as $i => $where) {
@@ -373,6 +370,9 @@ function elgg_get_metastring_based_objects($options) {
                }
        }
 
+       // remove identical where clauses
+       $wheres = array_unique($wheres);
+
        // evaluate join clauses
        if (!is_array($options['joins'])) {
                $options['joins'] = array($options['joins']);
index a11e6145c1a54d4aea1577e77204f4ba0da76bad..e283c05951989a14515b4eb8f862b7d0054fd0de 100644 (file)
@@ -170,9 +170,6 @@ function elgg_delete_river(array $options = array()) {
                $wheres[] = "rv.posted <= {$options['posted_time_upper']}";
        }
 
-       // remove identical where clauses
-       $wheres = array_unique($wheres);
-
        // see if any functions failed
        // remove empty strings on successful functions
        foreach ($wheres as $i => $where) {
@@ -183,6 +180,9 @@ function elgg_delete_river(array $options = array()) {
                }
        }
 
+       // remove identical where clauses
+       $wheres = array_unique($wheres);
+
        $query = "DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
 
        // remove identical join clauses
@@ -304,9 +304,6 @@ function elgg_get_river(array $options = array()) {
                }
        }
 
-       // remove identical where clauses
-       $wheres = array_unique($wheres);
-
        // see if any functions failed
        // remove empty strings on successful functions
        foreach ($wheres as $i => $where) {
@@ -317,6 +314,9 @@ function elgg_get_river(array $options = array()) {
                }
        }
 
+       // remove identical where clauses
+       $wheres = array_unique($wheres);
+
        if (!$options['count']) {
                $query = "SELECT DISTINCT rv.* FROM {$CONFIG->dbprefix}river rv ";
        } else {
index 1116d63f38a98e0d1ba34780b66f7117b2424b96..64feed5b2b3ad9fe5d6feb4df5cadb4314cb6e63 100644 (file)
@@ -184,9 +184,6 @@ function elgg_get_tags(array $options = array()) {
        $wheres[] = elgg_get_entity_time_where_sql('e', $options['created_time_upper'],
                $options['created_time_lower'], $options['modified_time_upper'], $options['modified_time_lower']);
 
-       // remove identical where clauses
-       $wheres = array_unique($wheres);
-
        // see if any functions failed
        // remove empty strings on successful functions
        foreach ($wheres as $i => $where) {
@@ -197,6 +194,8 @@ function elgg_get_tags(array $options = array()) {
                }
        }
 
+       // remove identical where clauses
+       $wheres = array_unique($wheres);
 
        $joins = $options['joins'];
 
index aef7a991e13a1976d6a80881dd64505fe6ffcfdd..59b48999cdd4496ddcdb5c9ffae7b31f4c45181a 100644 (file)
@@ -2789,4 +2789,13 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
                        $this->assertEqual($a_e_map[$a->id], $a->owner_guid);
                }
        }
+
+       public function testElggGetEntitiesBadWheres() {
+               $options = array(
+                       'container_guid' => 'abc'
+               );
+
+               $entities = elgg_get_entities($options);
+               $this->assertFalse($entities);
+       }
 }