* @param string $tableName
* Table referred to.
*
- * @return array
+ * @return CRM_Core_Reference_Interface[]
* structure of table and column, listing every table with a
* foreign key reference to $tableName, and the column where the key appears.
*/
$contactReferences = [];
$coreReferences = CRM_Core_DAO::getReferencesToTable('civicrm_contact');
foreach ($coreReferences as $coreReference) {
- if (!is_a($coreReference, 'CRM_Core_Reference_Dynamic')) {
+ if (
+ // Exclude option values
+ !is_a($coreReference, 'CRM_Core_Reference_Dynamic') &&
+ // Exclude references to other columns
+ $coreReference->getTargetKey() === 'id'
+ ) {
$contactReferences[$coreReference->getReferenceTable()][] = $coreReference->getReferenceKey();
}
}