Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Core: Candidate] Fix getFirstVisit method #4075

Merged
merged 17 commits into from
Jan 28, 2019
14 changes: 6 additions & 8 deletions php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class Candidate
function getProjectTitle()
{
$ProjectList = Utility::getProjectList();
return $ProjectList[$this->getProjectID()];
return $ProjectList[$this->getProjectID()] ?? '';
}

/**
Expand Down Expand Up @@ -621,15 +621,13 @@ class Candidate
$db = $factory->database();

$candID = $this->getCandID();

$query = "SELECT Visit_label
FROM session s JOIN candidate c ON (c.CandID = s.CandID)
WHERE c.CandID=:cid AND Date_Visit IS NOT NULL
ORDER BY Date_Visit";
$query = "SELECT Visit_label FROM session
WHERE CandID = :cid AND Date_visit IS NOT NULL
ORDER BY Date_visit, ID ASC LIMIT 1";
$where = array('cid' => $candID);
$vLabel = $db->pselectOne($query, $where);
$result = $db->pselectCol($query, $where);

return $vLabel;
return (is_array($result) && count($result) > 0) ? array_shift($result) : '';
}

/**
Expand Down