diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 467e776b20f6..b0a86a7843e6 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -42,13 +42,6 @@ class CRM_Core_DAO extends DB_DataObject { */ public static $_primaryKey = ['id']; - /** - * @return string[] - */ - protected function getPrimaryKey(): array { - return static::$_primaryKey; - } - /** * @return string */ @@ -58,7 +51,7 @@ protected function getFirstPrimaryKey(): string { // keys (which we support in codegen if not many other places) we return 'id' // simply because that is what we historically did & we don't want to 'just change' // it & break those extensions without doing the work to create an alternative. - return count($this->getPrimaryKey()) > 1 ? 'id' : $this->getPrimaryKey()[0]; + return count($this->keys()) > 1 ? 'id' : $this->keys()[0]; } /** @@ -525,31 +518,24 @@ public function initialize() { } /** - * Defines the default key as 'id'. + * Returns primary keys (usually ['id']) * - * @return array + * @return string[] */ public function keys() { - static $keys; - if (!isset($keys)) { - $keys = ['id']; - } - return $keys; + return static::$_primaryKey; } /** * Tells DB_DataObject which keys use autoincrement. * 'id' is autoincrementing by default. * + * FIXME: this should return all autoincrement keys not just the first. * * @return array */ public function sequenceKey() { - static $sequenceKeys; - if (!isset($sequenceKeys)) { - $sequenceKeys = [$this->getFirstPrimaryKey(), TRUE]; - } - return $sequenceKeys; + return [$this->getFirstPrimaryKey(), TRUE]; } /** diff --git a/ext/civiimport/Civi/BAO/Import.php b/ext/civiimport/Civi/BAO/Import.php index b7e956afc1a6..6c9f79d36468 100644 --- a/ext/civiimport/Civi/BAO/Import.php +++ b/ext/civiimport/Civi/BAO/Import.php @@ -61,13 +61,6 @@ public static function getImportTables(): array { return _civiimport_civicrm_get_import_tables(); } - /** - * @return string[] - */ - protected function getPrimaryKey(): array { - return self::$_primaryKey; - } - /** * Returns fields generic to all imports, indexed by name. * @@ -285,24 +278,4 @@ private static function getAllFields(string $tableName): array { return array_merge(self::getFieldsForTable($tableName), self::getSupportedFields()); } - /** - * Defines the default key as 'id'. - * - * @return array - */ - public function keys() { - return ['_id']; - } - - /** - * Tells DB_DataObject which keys use autoincrement. - * 'id' is autoincrementing by default. - * - * - * @return array - */ - public function sequenceKey() { - return ['_id', TRUE]; - } - } diff --git a/ext/search_kit/Civi/BAO/SK_Entity.php b/ext/search_kit/Civi/BAO/SK_Entity.php index 787ac96ddfac..90b696d14534 100644 --- a/ext/search_kit/Civi/BAO/SK_Entity.php +++ b/ext/search_kit/Civi/BAO/SK_Entity.php @@ -51,23 +51,4 @@ public static function tableHasBeenAdded(): bool { return TRUE; } - /** - * Defines the primary key(s). - * - * @return array - */ - public function keys() { - return ['_row']; - } - - /** - * Tells DB_DataObject which keys use autoincrement. - * Overrides the default 'id'. - * - * @return array - */ - public function sequenceKey() { - return ['_row', TRUE]; - } - }