aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2013-02-27 10:36:47 -0500
committerBrett Profitt <brett.profitt@gmail.com>2013-02-27 10:36:47 -0500
commit8f7bd6a446c85d8200e384ad320ea2507a850b0e (patch)
treec0b0ebeb7c323f4123c27da1124f134a3871651f /engine/lib
parent3cefc94d2a2a77402742098adc999e70cfc4b764 (diff)
downloadelgg-8f7bd6a446c85d8200e384ad320ea2507a850b0e.tar.gz
elgg-8f7bd6a446c85d8200e384ad320ea2507a850b0e.tar.bz2
Fixes #5066. Empty subtypes are handled the same way for both 'subtype' and 'subtypes'
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 25c927ac6..156eec040 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1219,14 +1219,24 @@ function elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pair
$subtype_ids = array();
if ($subtypes) {
foreach ($subtypes as $subtype) {
- // check that the subtype is valid (with ELGG_ENTITIES_NO_VALUE being a valid subtype)
- // @todo simplify this logic
- if (ELGG_ENTITIES_NO_VALUE === $subtype || $subtype_id = get_subtype_id($type, $subtype)) {
- $subtype_ids[] = (ELGG_ENTITIES_NO_VALUE === $subtype) ? ELGG_ENTITIES_NO_VALUE : $subtype_id;
- } else {
- $valid_subtypes_count--;
- elgg_log("Type-subtype '$type:$subtype' does not exist!", 'NOTICE');
+ // check that the subtype is valid
+ if (!$subtype && ELGG_ENTITIES_NO_VALUE === $subtype) {
+ // subtype value is 0
+ $subtype_ids[] = ELGG_ENTITIES_NO_VALUE;
+ } elseif (!$subtype) {
+ // subtype is ignored.
+ // this handles ELGG_ENTITIES_ANY_VALUE, '', and anything falsy that isn't 0
continue;
+ } else {
+ $subtype_id = get_subtype_id($type, $subtype);
+
+ if ($subtype_id) {
+ $subtype_ids[] = $subtype_id;
+ } else {
+ $valid_subtypes_count--;
+ elgg_log("Type-subtype '$type:$subtype' does not exist!", 'NOTICE');
+ continue;
+ }
}
}