aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-11-28 11:18:15 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-11-28 14:46:27 +0100
commitbf2c9be06640c1ce1fff6da893ddb55297069af9 (patch)
tree41d5d369720c7b99ceff237b0996db6df88a0759
parent154628daf46d2ace4bf90e05053696160b2b00c3 (diff)
downloadnextcloud-server-bf2c9be06640c1ce1fff6da893ddb55297069af9.tar.gz
nextcloud-server-bf2c9be06640c1ce1fff6da893ddb55297069af9.zip
concatenate queries with 'or'
-rw-r--r--lib/private/activitymanager.php16
-rw-r--r--tests/lib/activitymanager.php7
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php
index f31b121c8e8..e0ee7c1b055 100644
--- a/lib/private/activitymanager.php
+++ b/lib/private/activitymanager.php
@@ -247,16 +247,28 @@ class ActivityManager implements IManager {
* @return array
*/
function getQueryForFilter($filter) {
+
+ $conditions = array();
+ $parameters = array();
+
foreach($this->extensions as $extension) {
$c = $extension();
if ($c instanceof IExtension) {
$result = $c->getQueryForFilter($filter);
if (is_array($result)) {
- return $result;
+ list($condition, $parameter) = $result;
+ if ($condition && is_array($parameter)) {
+ $conditions[] = $condition;
+ $parameters = array_merge($parameters, $parameter);
+ }
}
}
}
- return array(null, null);
+ if (empty($conditions)) {
+ return array(null, null);
+ }
+
+ return array(' and ((' . implode(') or (', $conditions) . '))', $parameters);
}
}
diff --git a/tests/lib/activitymanager.php b/tests/lib/activitymanager.php
index 85f8320de09..0683eb68193 100644
--- a/tests/lib/activitymanager.php
+++ b/tests/lib/activitymanager.php
@@ -87,11 +87,14 @@ class Test_ActivityManager extends \Test\TestCase {
}
public function testQueryForFilter() {
+ $this->activityManager->registerExtension(function() {
+ return new SimpleExtension();
+ });
$result = $this->activityManager->getQueryForFilter('filter1');
$this->assertEquals(
array(
- '`app` = ? and `message` like ?',
- array('mail', 'ownCloud%')
+ ' and ((`app` = ? and `message` like ?) or (`app` = ? and `message` like ?))',
+ array('mail', 'ownCloud%', 'mail', 'ownCloud%')
), $result
);