return [];
}
- static $ufValues;
- if ($ufID && !isset($ufValues[$ufID])) {
+ if (!isset(Civi::$statics[__CLASS__][__FUNCTION__][$ufID])) {
$ufmatch = new CRM_Core_DAO_UFMatch();
$ufmatch->uf_id = $ufID;
$ufmatch->domain_id = CRM_Core_Config::domainID();
if ($ufmatch->find(TRUE)) {
- $ufValues[$ufID] = [
+ Civi::$statics[__CLASS__][__FUNCTION__][$ufID] = [
'uf_id' => $ufmatch->uf_id,
'uf_name' => $ufmatch->uf_name,
'contact_id' => $ufmatch->contact_id,
];
}
}
- return $ufValues[$ufID];
+ return Civi::$statics[__CLASS__][__FUNCTION__][$ufID] ?? NULL;
}
/**
--- /dev/null
+<?php
+
+/**
+ * Class CRM_Core_BAO_UFMatchTest
+ * @group headless
+ */
+class CRM_Core_BAO_UFMatchTest extends CiviUnitTestCase {
+
+ /**
+ * Don't crash if the uf_id doesn't exist
+ */
+ public function testGetUFValuesWithNonexistentUFId() {
+ $max_id = (int) CRM_Core_DAO::singleValueQuery('SELECT MAX(uf_id) FROM civicrm_uf_match');
+ $dontcrash = CRM_Core_BAO_UFMatch::getUFValues($max_id + 1);
+ $this->assertNull($dontcrash);
+ }
+
+}