From 63dd851214d502df5bf399831bd2346e0521c3f6 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 16 Aug 2022 19:10:02 -0700 Subject: [PATCH] DAO - Raise error if we don't get the expected PK Follow-up to #24275 --- CRM/Core/DAO.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 55b353c617..a3395fd424 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -543,7 +543,7 @@ class CRM_Core_DAO extends DB_DataObject { public function sequenceKey() { static $sequenceKeys; if (!isset($sequenceKeys)) { - $sequenceKeys = [$this->getPrimaryKey()[0], TRUE]; + $sequenceKeys = [CRM_Utils_Array::single($this->getPrimaryKey()), TRUE]; } return $sequenceKeys; } @@ -644,7 +644,7 @@ class CRM_Core_DAO extends DB_DataObject { // In practice the 'Import' entities are probably the only ones with a single // primary key that is not import. Should we check all if more than one? // Can do that when it comes up... - $primaryField = $this->getPrimaryKey()[0]; + $primaryField = CRM_Utils_Array::single($this->getPrimaryKey()); if (!empty($this->$primaryField)) { if ($hook) { $preEvent = new \Civi\Core\DAO\Event\PreUpdate($this); -- 2.25.1