Fix admin forms to not call deprecated functions
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 20 Dec 2023 23:42:55 +0000 (12:42 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 20 Dec 2023 23:52:41 +0000 (12:52 +1300)
CRM/Admin/Form.php
CRM/Core/DAO.php

index 873aa2961ad0d5576e72c1e57556db62a64004d0..dad95d94a946e0aea464e704a006e3d9b2c1505d 100644 (file)
@@ -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', [
index 9735820e2cbfdd4ef26547e43cdcd63ea4cd7b7f..7062e76140ce3dd2ab5a1aabd48a4983abf96f4f 100644 (file)
@@ -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