From badd3a8a4ae0ff8f6178bc5a0d4bc9f9e47ce2f5 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 21 Dec 2023 12:42:55 +1300 Subject: [PATCH] Fix admin forms to not call deprecated functions --- CRM/Admin/Form.php | 10 +++++++++- CRM/Core/DAO.php | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Form.php b/CRM/Admin/Form.php index 873aa2961a..dad95d94a9 100644 --- a/CRM/Admin/Form.php +++ b/CRM/Admin/Form.php @@ -15,6 +15,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\Utils\ReflectionUtils; + /** * Base class for admin forms. */ @@ -154,7 +156,13 @@ class CRM_Admin_Form extends CRM_Core_Form { if (isset($this->_id) && CRM_Utils_Rule::positiveInteger($this->_id)) { if ($this->retrieveMethod === 'retrieve') { $params = ['id' => $this->_id]; - $this->_BAOName::retrieve($params, $this->_values); + if (!empty(ReflectionUtils::getCodeDocs((new \ReflectionMethod($this->_BAOName, 'retrieve')), 'Method')['deprecated'])) { + CRM_Core_DAO::commonRetrieve($this->_BAOName, $params, $this->_values); + } + else { + // Are there still some out there? + $this->_BAOName::retrieve($params, $this->_values); + } } elseif ($this->retrieveMethod === 'api4') { $this->_values = civicrm_api4($this->getDefaultEntity(), 'get', [ diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 9735820e2c..7062e76140 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1520,6 +1520,8 @@ LIKE %1 /** * Fetch object based on array of properties. * + * @internal - extensions should always use the api + * * @param string $daoName * Name of the dao class. * @param array $params -- 2.25.1