Skip to content

Commit

Permalink
Remove automatic reset of query builder index
Browse files Browse the repository at this point in the history
Automatically resetting the index can cause named parameter conflicts
when multiple queries execute during the same process.
  • Loading branch information
jimsafley committed Dec 6, 2024
1 parent db89905 commit 7995236
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/src/Api/Adapter/AbstractEntityAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public function search(Request $request)
// Begin building the search query.
$entityClass = $this->getEntityClass();

$this->index = 0;
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('omeka_root')
Expand Down Expand Up @@ -700,7 +699,6 @@ public function findEntity($criteria, $request = null)
}

$entityClass = $this->getEntityClass();
$this->index = 0;
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('omeka_root')->from($entityClass, 'omeka_root');
foreach ($criteria as $field => $value) {
Expand Down Expand Up @@ -758,6 +756,14 @@ public function createAlias($prefix = 'omeka_')
return $alias;
}

/**
* Reset the index for query builder named parameters / aliases.
*/
public function resetIndex()
{
$this->index = 0;
}

/**
* Determine whether a string is a valid JSON-LD term.
*
Expand All @@ -779,7 +785,6 @@ public function isTerm($term)
*/
public function isUnique(EntityInterface $entity, array $criteria)
{
$this->index = 0;
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('e.id')
->from($this->getEntityClass(), 'e');
Expand Down

0 comments on commit 7995236

Please sign in to comment.