Merge pull request #2074 from FathiBenNasr/fix/getcontactbyemail-missing-columns

PdoAddressBook: GetContactByEmail() passed the wrong columns
This commit is contained in:
Maarten 2026-10-22 12:59:25 +02:00 • committed by GitHub
commit 9f0e6d946a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -723,14 +723,20 @@ class PdoAddressBook
$aParams[':search_lower'] = array($sLowerSearch, \PDO::PARAM_STR); $aParams[':search_lower'] = array($sLowerSearch, \PDO::PARAM_STR);
} }
$oContact = null; // This query selects id_contact only, so it must not be handed to
$iIdContact = 0; // getContactsFromPDO(), which unconditionally reads id_contact_str,
// changed, etag and jcard from every row. Look the contact up by id
// instead: GetContactByID() selects those columns, so the Contact it
// returns carries a real etag and changed value rather than 0.
$oStmt = $this->prepareAndExecute($sSql, $aParams);
if ($oStmt) {
$aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC);
if (\is_array($aFetch) && \count($aFetch) && !empty($aFetch[0]['id_contact'])) {
return $this->GetContactByID((int) $aFetch[0]['id_contact']);
}
}
$aContacts = $this->getContactsFromPDO( return null;
$this->prepareAndExecute($sSql, $aParams)
);
return $aContacts ? $aContacts[0] : null;
} }
/** /**