#3496 closed Defect (fixed)
elgg_get_river() doesn't work properly when supplying an array of subtypes
| Reported by: | jtilson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Elgg 1.8.2 |
| Component: | Core | Version: | 1.8 Beta |
| Severity: | minor | Keywords: | |
| Cc: | brett@… | Difficulty: | easy |
Description
Nothing is returned by elgg_get_river() if you supply an array of subtypes via the options
The following is an example:
$subtypes = array('blog', 'thewire', 'bookmarks');
$options = array(
'subtypes' => $subtypes,
);
$river_items = elgg_get_river($options);
Executing the above returns nothing at all, but trying each subtype individually works fine, ie:
$subtypes = array('blog');
I dumped the output of
elgg_get_river_type_subtype_where_sql('rv', $options['types'],
$options['subtypes'], $options['type_subtype_pairs']);
when running the first block of code, and I received the following SQL:
((rv.subtype = 'blog') AND (rv.subtype = 'bookmarks') AND (rv.subtype = 'thewire'))
Shouldn't this be:
((rv.subtype = 'blog') OR (rv.subtype = 'bookmarks') OR (rv.subtype = 'thewire'))
Change History (7)
comment:1 Changed 2 years ago by cash
- Difficulty set to easy
- Milestone changed from Needs Review to Elgg 1.8
comment:2 Changed 21 months ago by Brett Profitt
- Resolution set to fixed
- Status changed from new to closed
Fixes #3496. Using OR to concatenate unpaired type and subtype clauses in elgg_get_river_type_subtype_where_sql().
Changeset: f280887c7df563dd3af8ad1ccc8f442c2d101264
comment:3 Changed 21 months ago by jtilson
- Resolution fixed deleted
- Status changed from closed to reopened
Just found a problem with the fix, now when you supply one (or more) subtypes the query will return either: type OR subtype ie:
WHERE ((rv.type = 'object') OR (rv.subtype = 'blog')) OR (rv.subtype = 'thewire'))
This will return just about anything.. We'd actually want something more like:
((rv.type = 'object') AND ((rv.subtype = 'blog') OR (rv.subtype = 'thewire')))
comment:4 Changed 18 months ago by Danny Navarro
Refs #3496 improving type/subtype handling for the river
Changeset: 583e52700ca5c7ed1d0dd58054dbd08208c0c158
comment:5 Changed 18 months ago by cash
- Milestone changed from Elgg 1.8.0 to Elgg 1.8.2
comment:6 Changed 18 months ago by cash
- Resolution set to fixed
- Status changed from reopened to closed
Fixes #3496 finished up this ticket by updating unit test and using more parantheses to make it clear how the OR/AND gets applied
Changeset: 6cc08f83225237d0cd57e0a5c0ebec0a8327aa30
comment:7 Changed 18 months ago by Danny Navarro
Refs #3496 improving type/subtype handling for the river
Changeset: d9e595ec0e44a4143c5e50eac8a8f83d66c03569

Thanks for debugging this, Jeff. Looks like elgg_get_river_type_subtype_where_sql() has a bug.