Skip to content

Commit

Permalink
BUGFIX: Do not add node type constraint query if no constraints defined
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Apr 10, 2020
1 parent 101ab5a commit 8aaf999
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Classes/Domain/Repository/NodeDataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,33 @@ class NodeDataRepository extends Repository

/**
* @param string $workspaceName
* @param integer $firstResult
* @param integer $maxResults
* @param int $firstResult
* @param int $maxResults
* @return IterableResult
* @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception
*/
public function findAllBySiteAndWorkspace($workspaceName, $firstResult = 0, $maxResults = 1000): IterableResult
public function findAllBySiteAndWorkspace(string $workspaceName, int $firstResult = 0, int $maxResults = 1000): IterableResult
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->entityManager->createQueryBuilder();

$excludedNodeTypes = array_keys(array_filter($this->nodeTypeIndexingConfiguration->getIndexableConfiguration(), static function($value) {
return !$value;
}));

$queryBuilder->select('n.Persistence_Object_Identifier persistenceObjectIdentifier, n.identifier identifier, n.dimensionValues dimensions, n.nodeType nodeType, n.path path')
->from(NodeData::class, 'n')
->where('n.workspace = :workspace AND n.removed = :removed AND n.movedTo IS NULL')
->andWhere($queryBuilder->expr()->notIn('n.nodeType', $excludedNodeTypes))
->setFirstResult((integer)$firstResult)
->setMaxResults((integer)$maxResults)
->setParameters([
':workspace' => $workspaceName,
':removed' => false,
]);

$excludedNodeTypes = array_keys(array_filter($this->nodeTypeIndexingConfiguration->getIndexableConfiguration(), static function($value) {
return !$value;
}));

if(!empty($excludedNodeTypes)) {
$queryBuilder->andWhere($queryBuilder->expr()->notIn('n.nodeType', $excludedNodeTypes));
}

return $queryBuilder->getQuery()->iterate();
}

Expand Down

0 comments on commit 8aaf999

Please sign in to comment.