From ff8d01ebdf58a8c6cecb65b4dce3fa550e431f3c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 28 Feb 2023 19:04:36 -0500 Subject: [PATCH] Delete long-deprecated functions --- CRM/Contact/BAO/Contact.php | 30 ---------- CRM/Contact/BAO/Contact/Location.php | 38 ------------ CRM/Core/DAO.php | 43 -------------- CRM/Core/OptionGroup.php | 88 ---------------------------- api/v3/utils.php | 19 ------ 5 files changed, 218 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index f3ca57be80..c9c9dc964c 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -1147,36 +1147,6 @@ WHERE civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer'); } } - /** - * Function to set is_delete true or restore deleted contact. - * - * @param CRM_Contact_DAO_Contact $contact - * Contact DAO object. - * @param bool $restore - * True to set the is_delete = 1 else false to restore deleted contact, - * i.e. is_delete = 0 - * - * @deprecated - * - * @return bool - * @throws \CRM_Core_Exception - */ - public static function contactTrashRestore($contact, $restore = FALSE) { - CRM_Core_Error::deprecatedFunctionWarning('Use the api'); - - if ($restore) { - CRM_Core_Error::deprecatedFunctionWarning('Use contact.create to restore - this does nothing much'); - // @todo deprecate calling contactDelete with the intention to restore. - $updateParams = [ - 'id' => $contact->id, - 'is_deleted' => FALSE, - ]; - self::create($updateParams); - return TRUE; - } - return self::contactTrash($contact); - } - /** * Get contact type for a contact. * diff --git a/CRM/Contact/BAO/Contact/Location.php b/CRM/Contact/BAO/Contact/Location.php index 2e3a0fdb99..13f533ba66 100644 --- a/CRM/Contact/BAO/Contact/Location.php +++ b/CRM/Contact/BAO/Contact/Location.php @@ -59,44 +59,6 @@ class CRM_Contact_BAO_Contact_Location { return $returnParams; } - /** - * @deprecated Not used anywhere, use the Phone API instead - * Get the sms number and display name of a contact. - * - * @param int $id - * Id of the contact. - * @param string|null $type - * - * @return array - * tuple of display_name and sms if found, or (null,null) - */ - public static function getPhoneDetails($id, $type = NULL) { - CRM_Core_Error::deprecatedFunctionWarning('Phone.get API instead'); - if (!$id) { - return [NULL, NULL]; - } - - $cond = NULL; - if ($type) { - $cond = " AND civicrm_phone.phone_type_id = '$type'"; - } - - $sql = " - SELECT civicrm_contact.display_name, civicrm_phone.phone, civicrm_contact.do_not_sms - FROM civicrm_contact -LEFT JOIN civicrm_phone ON ( civicrm_phone.contact_id = civicrm_contact.id ) - WHERE civicrm_phone.is_primary = 1 - $cond - AND civicrm_contact.id = %1"; - - $params = [1 => [$id, 'Integer']]; - $dao = CRM_Core_DAO::executeQuery($sql, $params); - if ($dao->fetch()) { - return [$dao->display_name, $dao->phone, $dao->do_not_sms]; - } - return [NULL, NULL, NULL]; - } - /** * Get the information to map a contact. * diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index b8c672a596..f63391c46d 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1080,25 +1080,6 @@ class CRM_Core_DAO extends DB_DataObject { } } - /** - * Check if there is a given column in a specific table. - * - * @deprecated - * @see CRM_Core_BAO_SchemaHandler::checkIfFieldExists - * - * @param string $tableName - * @param string $columnName - * @param bool $i18nRewrite - * Whether to rewrite the query on multilingual setups. - * - * @return bool - * true if exists, else false - */ - public static function checkFieldExists($tableName, $columnName, $i18nRewrite = TRUE) { - CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_BAO_SchemaHandler::checkIfFieldExists'); - return CRM_Core_BAO_SchemaHandler::checkIfFieldExists($tableName, $columnName, $i18nRewrite); - } - /** * Scans all the tables using a slow query and table name. * @@ -2441,30 +2422,6 @@ SELECT contact_id } } - /** - * @param string $prefix - * @param bool $addRandomString - * @param null $string - * - * @return string - * @deprecated - * @see CRM_Utils_SQL_TempTable - */ - public static function createTempTableName($prefix = 'civicrm', $addRandomString = TRUE, $string = NULL) { - CRM_Core_Error::deprecatedFunctionWarning('Use CRM_Utils_SQL_TempTable interface to create temporary tables'); - $tableName = $prefix . "_temp"; - - if ($addRandomString) { - if ($string) { - $tableName .= "_" . $string; - } - else { - $tableName .= "_" . md5(uniqid('', TRUE)); - } - } - return $tableName; - } - /** * @param bool $view * @param bool $trigger diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 04e989436c..b0701cc5f2 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -328,94 +328,6 @@ WHERE v.option_group_id = g.id } } - /** - * @deprecated - use CRM_Core_PseudoConstant::getLabel - * - * @param string $groupName - * @param $value - * @param bool $onlyActiveValue - * - * @return null - */ - public static function getLabel($groupName, $value, $onlyActiveValue = TRUE) { - CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_PseudoConstant::getLabel'); - if (empty($groupName) || - empty($value) - ) { - return NULL; - } - - $query = " -SELECT v.label as label ,v.value as value -FROM civicrm_option_value v, - civicrm_option_group g -WHERE v.option_group_id = g.id - AND g.name = %1 - AND g.is_active = 1 - AND v.value = %2 -"; - if ($onlyActiveValue) { - $query .= " AND v.is_active = 1 "; - } - $p = [ - 1 => [$groupName, 'String'], - 2 => [$value, 'Integer'], - ]; - $dao = CRM_Core_DAO::executeQuery($query, $p); - if ($dao->fetch()) { - return $dao->label; - } - return NULL; - } - - /** - * @deprecated - * - * This function is not cached. - * - * @param string $groupName - * @param $label - * @param string $labelField - * @param string $labelType - * @param string $valueField - * - * @return null - */ - public static function getValue( - $groupName, - $label, - $labelField = 'label', - $labelType = 'String', - $valueField = 'value' - ) { - if (empty($label)) { - return NULL; - } - - CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_PseudoConstant::getKey'); - - $query = " -SELECT v.label as label ,v.{$valueField} as value -FROM civicrm_option_value v, - civicrm_option_group g -WHERE v.option_group_id = g.id - AND g.name = %1 - AND v.is_active = 1 - AND g.is_active = 1 - AND v.$labelField = %2 -"; - - $p = [ - 1 => [$groupName, 'String'], - 2 => [$label, $labelType], - ]; - $dao = CRM_Core_DAO::executeQuery($query, $p); - if ($dao->fetch()) { - return $dao->value; - } - return NULL; - } - /** * Get option_value.value from default option_value row for an option group * diff --git a/api/v3/utils.php b/api/v3/utils.php index 2a03f8e4a7..11507b7c0a 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -457,25 +457,6 @@ function _civicrm_api3_store_values(array $fields, array $params, &$values): boo return $valueFound; } -/** - * Returns field names of the given entity fields. - * - * @deprecated - * @param array $fields - * Fields array to retrieve the field names for. - * @return array - */ -function _civicrm_api3_field_names($fields) { - CRM_Core_Error::deprecatedFunctionWarning('array_column'); - $result = []; - foreach ($fields as $key => $value) { - if (!empty($value['name'])) { - $result[] = $value['name']; - } - } - return $result; -} - /** * Get function for query object api. * -- 2.25.1