Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions modules/dataquery/php/query.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,7 @@ class Query implements \LORIS\StudyEntities\AccessibleResource,
throw new \Exception("Unhandled operator: " . $crit['op']);
}

// FIXME: Verify visits, test was done with candidate scope data
$visitlist = null;
if (isset($crit['visits'])) {
$visitlist = $crit['visits'];
}
$visitlist = $crit['visits'] ?? null;

\Profiler::checkpoint("Calling engine get matches");
$matches = $engine->getCandidateMatches($term, $visitlist);
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Query/SQLQueryEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getCandidateMatches(
$this->addWhereClause("c.Active='Y'");
$prepbindings = [];

$this->buildQueryFromCriteria($term, $prepbindings);
$this->buildQueryFromCriteria($term, $prepbindings, $visitlist);

$query = 'SELECT DISTINCT c.CandID FROM';

Expand Down Expand Up @@ -582,7 +582,6 @@ protected function buildQueryFromCriteria(
);

if ($visitlist != null) {
$this->addTable("LEFT JOIN session s ON (s.CandidateID=c.ID AND s.Active='Y')");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change.

My understanding from the PR description is that it was causing some kind of problem, but calling addTable with the same string multiple times should only add it once, so calling it a second time shouldn't change the results at all. That's the point of addTable.

If this is unnecessary because buildQueryFromCriteria is doing it, why is it only the addTable and not the rest of the duplicated logic that needs to be removed?

Since the addWhereClause on line 593 remains this code path should be making sure the table is added to the query before referencing it. Unless I'm missing something I think either the whole thing should be removed or none of it should be.

$inset = [];
$i = count($prepbindings);
foreach ($visitlist as $vl) {
Expand Down
Loading