From: Eileen McNaughton Date: Wed, 20 Dec 2023 23:42:55 +0000 (+1300) Subject: Fix admin forms to not call deprecated functions X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=badd3a8a4ae0ff8f6178bc5a0d4bc9f9e47ce2f5;p=civicrm-core.git Fix admin forms to not call deprecated functions --- 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