PHRAS-2497 #comment port to 4.1 Search issue when query mix data from Public and Private field

#time 2h
This commit is contained in:
aina-esokia
2019-04-23 12:10:25 +04:00
parent 44fb25912b
commit 47d974a466
8 changed files with 50 additions and 20 deletions

View File

@@ -10,13 +10,13 @@ class QueryHelper
{
private function __construct() {}
public static function wrapPrivateFieldQueries(array $fields, \Closure $query_builder)
public static function wrapPrivateFieldQueries(array $private_fields, array $unrestricted_fields, \Closure $query_builder)
{
// We make a boolean clause for each collection set to shrink query size
// (instead of a clause for each field, with his collection set)
$fields_map = [];
$collections_map = [];
foreach ($fields as $field) {
foreach ($private_fields as $field) {
$collections = $field->getDependantCollections();
$hash = self::hashCollections($collections);
$collections_map[$hash] = $collections;
@@ -31,7 +31,7 @@ class QueryHelper
foreach ($fields_map as $hash => $fields) {
// Right to query on a private field is dependant of document collection
// Here we make sure we can only match on allowed collections
$query = $query_builder($fields);
$query = $query_builder(array_merge($fields, $unrestricted_fields));
if ($query !== null) {
$queries[] = self::restrictQueryToCollections($query, $collections_map[$hash]);
}